admin管理员组文章数量:1316974
I have a forgot password form, on which when the user enters an email it hits the backend and sends out an email link to user as below.
The user clicks on the link, which invokes the back-end service. How can i control this url via angular
? So, basically this calls a back-end resouce, but i want this url to be handled in front-end too.
If this question is not so clear, can anyone show me an example of forgot password implementation in AngularJS and NodJs or any backend.
I have a forgot password form, on which when the user enters an email it hits the backend and sends out an email link to user as below.
The user clicks on the link, which invokes the back-end service. How can i control this url via angular
? So, basically this calls a back-end resouce, but i want this url to be handled in front-end too.
If this question is not so clear, can anyone show me an example of forgot password implementation in AngularJS and NodJs or any backend.
Share Improve this question asked Oct 3, 2015 at 4:07 ShaneShane 5,68715 gold badges57 silver badges82 bronze badges 3- Why don't you change the link in the following way:localhost:3000/#/resetpassword/55356236t663623 And have route for this with routeProvider or stateProvider – Raju Bera Commented Oct 3, 2015 at 4:09
- Why don't you change the link in the following way: localhost:3000/#/resetpassword/55356236t663623 And have route for this in your angularjs app with routeProvider or stateProvider – Raju Bera Commented Oct 3, 2015 at 4:13
-
You should have a "forgot password" page like this:
https://example./forgotpw/?token=xxxxxxxxx
, then that page should provide a front-end experience to the user, get the new password, and send an AJAX request to your backend script. – Maximillian Laumeister Commented Oct 3, 2015 at 4:20
1 Answer
Reset to default 5if you can change the link in the email then change it in the following way:
http://localhost:3000/#/resetpassword/<token>
Now in your angular route you need to listen to this route as following:
angular.module('myApp', ['ngRoute'])
.controller('ResetPasswordController', function($scope, $route, $routeParams, $location) {
//password resetting functionality
})
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/resetpassword/:token', {
templateUrl: 'reset.html',
controller: 'ResetPasswordController',
resolve: {
// Call the backend service to check if the token is valid
verifyToken: function($q, $route) {
var deferred = $q.defer();
$http({
method: 'GET',
url: '/reset/' + $route.current.params.token
}).success(function (data) {
deferred.resolve(data);
}).error(function (msg) {
deferred.reject(msg);
});
return deferred.promise;
}
}
})
});
本文标签: javascriptAngularJS Forgot passwordStack Overflow
版权声明:本文标题:javascript - AngularJS Forgot password - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742019314a2414369.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论