Ember Simple Auth various redirects after authentication

I use Ember simple auth in my application and it works fine, but I came across a script that I have problems around.

The library allows you to specify the route to redirect after successful authentication by overriding routeAfterAuthentication: 'index' . This works fine, however, I am in a situation where I want to have two different types of redirects. When the user first logs in, I want them to go to /dashboard , but when they first log in and authenticate, I want them to go /settings .

I was hoping I could do something like this after successfully creating the account, but still trying to use the routeAfterAuthentication option to navigate:

 var _this = this; this.set('identification', _this.get('email')); this.set('password', password); this.send('authenticate', function() { _this.transitionToRoute('settings'); }, function() {}); 

Is there a way to indicate which route to go after authentication on a one-time basis? Maybe there is a better way to register someone after creating an account without going through the authenticate() method?

+5
source share
1 answer

You can simply override the sessionAuthenticated method in the application route and implement your own logic. Beware, however, that the default implementation will not always transition to routeAfterAuthentication — if there was a previously intercepted transition stored in the session, sessionAuthenticated will repeat this.

+7
source

Source: https://habr.com/ru/post/1200264/


All Articles