7
Leave a Reply

avatar
4 Comment threads
3 Thread replies
5 Followers
 
Most reacted comment
Hottest comment thread
7 Comment authors
cklMauroFedericoKamleshjuhee Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Mary User
Guest
Mary User

Thanks, nice simple explanation.
How would you handle different access Levels? e.g. in WordPress you have Admin, Authors etc.

Say I have Level 1, Level 2, Level 3 users how would I save, and use their access level using this technique?

Athishay
Guest
Athishay

I guess you need to take care of that in your backend API’s.

juhee
Guest
juhee

Thank you. But there’s an error. Why is that? I did the same thing.
Error: StaticInjectorError(AppModule)[AuthGuardService -> AuthenticationService]:
StaticInjectorError(Platform: core)[AuthGuardService -> AuthenticationService]:
NullInjectorError: No provider for AuthenticationService!

Kamlesh
Guest

Thank you for nice article. This example working fine.

But, How I can handle hardware back button on login page after user logged in, both in sidebar and tabs page application. In device after login success tabs page comes than after press back button than login page show again 🙁

I tried to add a new authGaurd for login page, but blank page comes for few sec.

How can handle this? Please post a example.

Thanks,
Kamlesh

Mauro
Guest
Mauro

instead of

this.router.navigate([‘dashboard’]);

use

this.navCtrl.navigateRoot(‘dashboard’)

to do this you have to import NavController first:

import { NavController } from ‘@ionic/angular’;

and in your constructor:

constructor(private navCtrl: NavController)

Federico
Guest
Federico

The big issue with this approach (that is the same that i saw in many others tutorials, btw) is that authguard check BEFORE that autentication service even be created, so if you refresh the page the first thing you say is app root (whatever it is, in my case login page) and only AFTER will subscribe for changing in authState (that will be fired in constructor service itself). Basically, login page appears for 1 sec or so. And i don’t like it.

ckl
Guest
ckl

Hi, how to solve the 1 sec display? What alternative approach you suggest?