lynndylanhurley / ng-token-auth

Token based authentication module for angular.js.
Do What The F*ck You Want To Public License
1.8k stars 234 forks source link

auth:password-reset-confirm-success never seems to be broadcast #353

Open stansongman opened 7 years ago

stansongman commented 7 years ago

I'm using ng-token-auth on my mobile app (ionic/angular) with Devise Token Auth on rails backend. I've been struggling with the password reset process. 'auth:password-reset-confirm-success' is never broadcast after I click on the reset email link. I may just be doing this all wrong, but I wanted to do the password reset from the app after the user hit the confirm link in the email, rather than posting a web form, having them reset there, then go back to the app, etc.

UPDATE: To get the broadcast, you need to have ValidateToken run. my $authProvider.configure:

.config(function($authProvider,apiUrl){
              $authProvider.configure({
                        apiUrl: apiUrl,
                        forceValidateToken: true,
                        storage: 'localStorage'
                  });
})

Then after making the reset request call, I change the state back to SignIn, which forces a page load and ValidateToken, and I get the broadcast. Now, onto handling the password reset from the app.

Never mind, it doesn't work the way I had imagined. I am unable to make password reset work between my mobile app and the rails server.

mxmzb commented 7 years ago

I am trying to achieve just the same, my optimal password reset flow would be:

  1. user requests reset mail from the app
  2. user receives email and clicks the reset link from the mail
  3. user is redirected to the app from there (whether it's emulated on my localhost in dev environment or on the app on a real device)
  4. user is signed in for one session and is asked to set a new password

however, I can't get the bit in 3. working where the user is signed in after the click on the link. any help or clarification whether this can even work as I hope is highly appreciated.