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
Nebular Login not redirecting if already logged in #994
Comments
Hi @iosif-bancioiu, this is not currently possible out of the box, so you would need to implement a custom route guard to track this and redirect. |
Thanks, then i will untick the bug report and mark it as a feature request, maybe someday it will be available out of the box :) |
@nnixaa one issue with this guard
If the user is not authenticated, return true is never hit, do you have any hints on this? Thanks! |
@iosif-bancioiu, I believe there is no need in the |
@iosif-bancioiu You can definitely solve this by doing a check in your In my case, my import { Component, OnInit } from '@angular/core';
import { NbLoginComponent, NbAuthJWTToken } from '@nebular/auth';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
})
export class LoginComponent extends NbLoginComponent implements OnInit {
// no constructor
ngOnInit() {
this.service.onTokenChange().subscribe((token: NbAuthJWTToken) => {
if (token.isValid()) {
this.router.navigate(['pages/dashboard']); // Your redirection goes here
}
});
}
} Note that I don't have to inject anything in the constructor because the parent class (NbLoginComponent) already have everything I need. Hope this helps. |
please explain how to direct sucess to external url, like any other websites |
@vikramsparamesh I found a workaround.
|
Issue type
I'm submitting a ... (check one with "x")
Issue description
Current behavior:
Login component not redirecting if already logged in. For example, you log in, you get redirected to some page, then if you go by url to Login again, you can login again, even if you did not log out and so on (the token is also still there)
Expected behavior:
Redirect to success redirect specified page if the user is authenticated
Steps to reproduce:
Login, and navigate again to login page and you will be able to login as many times as you wish
Related code:
Other information:
npm, node, OS, Browser
Angular, Nebular
The text was updated successfully, but these errors were encountered: