AngularJS忘记密码 [英] AngularJS Forgot password
问题描述
我有一个忘记密码的表单,当用户输入电子邮件时,它会在后端打到后端并向用户发送电子邮件链接,如下所示.
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.
用户单击链接,这将调用后端服务.如何通过angular
控制此URL?因此,基本上,这称为后端资源,但我也希望在前端也处理此url.
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.
如果这个问题不太清楚,谁能给我看看在AngularJS和NodJs或任何后端中忘记密码实现的示例.
If this question is not so clear, can anyone show me an example of forgot password implementation in AngularJS and NodJs or any backend.
推荐答案
如果您可以更改电子邮件中的链接,则可以通过以下方式进行更改:
if 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;
}
}
})
});
这篇关于AngularJS忘记密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!