Angular 6 Tutorial 17: Routing Protection (Login App Part 3)

preview_player
Показать описание
This tutorial shows you how to protect routes using guards in angular and implement them in a simple login application.

Рекомендации по теме
Комментарии
Автор

love your video.Keep up the good work and this concise short tutorials are very useful! for implementation & in case of sometimes easy to come back too!

AMANSHARMA-pyjw
Автор

Thank you very much bro. I already used auth guard before but this time I forgot how to. And this video reminds me of how it works. ^_^

markianbernardo
Автор

in the authservice. you're refering to data.success
what is data.success and where does the value come from?
is it from the HTTP response?

lassepoulsen
Автор

Nicely done, helped me a lot. Thanks!

gauravjoshi
Автор

I love your tutorial. But how and when did you add the "import [ observable ] from 'rxjs/Observable'; I think I missed something..

RonaldZiembinski
Автор

Thank you for the tutorial. I have a problem: Guards are not working for me. I have an app.route.ts file where i'm putting my routes array, i'm using angular 6 new property " providedIn: 'root' " on decorator @Injectable so i don't have to put the guard on the app.module file, not in the imports nor in the providers section. My backend is an MongoDB accessed through NodeJS API. I'm currently returning a well formed JWT and managing " isLoggedIn " variable according to that JWT.

I'm also injecting my auth service into my guard file so i can use " this._auth.isLoggedIn() " (yeah, as a method), but the guards just doesn't work... not throwing error on browser nor in Visual Code terminal...

"Protected" routes still can be accessed using an <a> tag with routerLink, a button with " " action, or just typing the route on browser's address bar.

Don't know what else can i do to manage this

MayOcampo
Автор

woww....that's awesome bro it works fine

bandlarupesh
Автор

I did the same thing but it doesn't seem to work for me.
in login.component.ts you have private Auth object where you set the loggedInStatus to true when login successfuly,
but in auth.guard.ts, you have its own private auth object which is different from the one you set in login componet,
I think that's why I don't get true for this.auth.isLoggedIn in auth guard, am i right? otherwise why I don't get true in auth guard even though it's set to true in login component? Please advice. Thanks.

ehuang
Автор

Getting 404 error for auth.php after starting the server php -S 0.0.0.0:1234

vivekshingala
Автор

Hi, I get an error on the database.php file when running and the admin page shows loading. What am I doing wrong

The error message is
Http failure during parsing for [url]
Ok: false
Status: 200
StatusText: OK

GlenBondMogane
Автор

Thanks for the explenation but to be honest, you should buy a new microphone. Its really hard to understand you.

EspaniaBerserk
Автор

@Injectable({
providedIn: 'root'
})

we don't have to add AuthService in the providers in login component. Once I removed it, it started working now.
I'm new to angular, took me so long to figure out every hiccup.

ehuang
Автор

Did he just say "... go to hell, or whatever." ? :D

zer
Автор

Great video. But please don't talk too much, just say important things. Thanks.

rommelrueco