Closed diegopq closed 2 years ago
User goes to /login
. Skips authentication, it redirects him to /home
.
Then if (_authBloc.state.skipLogin && state.location != '/home')
is if (true && false)
, so the else
block runs.
final isInLoginPage = state.location == '/login';
is false, he's not on /login
now, he was redirected to /home
.
Lastly if (!userAutheticated) return isInLoginPage ? null : '/login';
is if (!false) return false ? null : /login
- this part redirects him back.
Did I explain it good enough?
User goes to
/login
. Skips authentication, it redirects him to/home
. Thenif (_authBloc.state.skipLogin && state.location != '/home')
isif (true && false)
, so theelse
block runs.
final isInLoginPage = state.location == '/login';
is false, he's not on/login
now, he was redirected to/home
. Lastlyif (!userAutheticated) return isInLoginPage ? null : '/login';
isif (!false) return false ? null : /login
- this part redirects him back.Did I explain it good enough?
yes
I want to handle the redirection when a user authenticates and also if the user decides to skip the login, I use bloc as a state manager. The redirection works only if the user is authenticated but it doesn't work when the user decides to skip the login and it throws me a "redirect loop" exception. what the exception tells me is that it goes from login to home and then to login, the code inside the redirect callback is as follows:
This is the exception that is thrown:
I don't know why it tries to redirect to login when login is skipped