Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: email confirmation token URI with Rails API #824

Closed
CJYate opened this issue Feb 1, 2017 · 2 comments
Closed

Question: email confirmation token URI with Rails API #824

CJYate opened this issue Feb 1, 2017 · 2 comments

Comments

@CJYate
Copy link

CJYate commented Feb 1, 2017

I'm using :confirmable in my user model, in a pure API app with Javascript front-end.

The link in the email refers to the server address and port (in the development situation something like localhost:3000/api/auth/confirmation_token..), whilst we want to be redirected to the front-end (i.e. something like localhost:3001/confirmed).

I think I would rather the confirmation came through the front-end rather than the API. It feels wrong for external actors to access the API directly.

But even if they did, the redirect link address is wrong. Unless a new host is specified, it points to the URI confirmed, and will hit the back-end server instead.

This redirection url is configured in ng-token-auth's "confirmationSuccessUrl", and I'd need to get the host address/port of the front-end server; I could presumably do this via a function, but the auth configuration needs to be a static string.

How do other people use this feature? Does it require some custom code to pass the token through front-end to back-end? Any hints?

@CJYate
Copy link
Author

CJYate commented Feb 1, 2017

Note: I also need to implement "Invitable". It may be that following this guide
http://gabrielhilal.com/2015/11/07/integrating-devise_invitable-into-devise_token_auth/
will answer some questions

@CJYate
Copy link
Author

CJYate commented Feb 1, 2017

Well... It seems this is now working OK:

http://localhost:3000/api/auth/confirmation?config=default&confirmation_token=asdfasdf&redirect_url=http%3A%2F%2Flocalhost%3A3001%2F

I guess the fact that I reverted back to the following settings at some point, fixes the immediate problem:

  $authProvider.configure( {
    confirmationSuccessUrl: window.location.href,
    emailRegistrationPath: '/api/auth',
    accountUpdatePath: '/api/auth',
    accountDeletePath: '/api/auth',
    passwordResetPath: '/api/auth/password',
    passwordUpdatePath: '/api/auth/password',
    passwordResetSuccessUrl: window.location.href,
    apiUrl: 'http://localhost:3000',
    tokenValidationPath: '/api/auth/validate_token',
    emailSignInPath: '/api/auth/sign_in',
    signOutUrl: '/api/auth/sign_out',
    storage: 'localStorage'
  } );
}

@CJYate CJYate closed this as completed Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant