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
Add a ment  | 

1 Answer 1

Reset to default 5

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;
      }
    }
  })
});

本文标签: javascriptAngularJS Forgot passwordStack Overflow