silverbux / laravel-angular-admin

Laravel + Angularjs + Bootstrap + AdminLTE binded by Gulp workflow Admin Dashboard Boilerplate / Starter.
http://silverbux.github.io/laravel-angular-admin/
MIT License
925 stars 414 forks source link

Url Redirection and Getting Http Response #71

Closed aksuhana closed 7 years ago

aksuhana commented 7 years ago

Hello, I am unable to understand the flow of url and http response. For example , if in login template there is url '/login' but in route.php I am unable to found such relationship which returns success after correct credentials. And also I am stuck in others url too. I have worked on Larave 5.0,5.2 and AngularJs basically http request and response. Or if possible then share me some docs so that I can be able to understand the flow of the project. Please help me. Thanks in advance

RamiMustaklem commented 7 years ago

@aksuhana /login route is a frontend route, you will find it in the routes configurations inside the angular folder, it posts a request to /api/user/authenticate or something like that. There isn't a connection between laravel and angularjs except for the index.blade.php which loads all angular files, other than that the frontend only takes data from the laravel api calls. You should start with smaller, less complex projects in laravel and angularjs, this is a relatively complex integration between angularjs and a lot of libraries and laravel and a lot of libraries.

aksuhana commented 7 years ago

Thanks. One thing I am interested to know about the project is that, as there isn't a connection between laravel and angularjs except for the index.blade.php then How session is maintained using angular js as front end or JWT please explain it me in detail. I am stuck here. thanks in advance.

silverbux commented 7 years ago

hi @aksuhana this is the code responsible for it API.service.js, it adds the token into request headers which is recognized by laravel api endpoints.

so right after user do a successful login the endpoint returns a token which angularjs save into browser local storage.

aksuhana commented 7 years ago

Thanks sir , but what I have seen that after storing value in local storage and then search in browser new tab windows it disappears, if such, then how session maintains after putting jwt (token) in browsers window browser local storage at It should destroy in browser new tab. But in this case still session maintains. Thanks for your great time for me. Thanks in advance for your valuable suggestion or reply

RamiMustaklem commented 7 years ago

@aksuhana localStorage persists even after closing tab or browser unless deleted explicitly or by key (an example which happens after logout if you've noticed in the code) sessionStorage persists only per browser session, so it deleted itself after closing the whole browser not a tab.

so if you have no token in storage it will redirect you to login page and calls to api will not be authenticated. (now that's what should happen and to the extent of my knowledge also within the code here)

What's even more secure and best is to keep your site's data including token in cookie storage using ngCookies or cookie specialized package.