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.
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;
}
}
})
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.