Cool I didn't know there was a web dev thread on GAF (silly me, of course there's a thread about everything)!
Just to introduce me in, I'm currently studying the MEAN stack because nowadays the cool kids apparently hate LAMP and, being totally tired of doing dozens of todo apps tutorials, I thought of just trying to figure out stuff diving into some actual code.
I've tried the
angular-fullstack generator and it's mostly clear how it works, except how it handle the admin authentication.
Here's what it generates:
https://github.com/DaftMonk/fullstack-demo
Basically, you can login as either admin or user. Both have a settings page (where you can change your password), and only admin as an admin page (where you can delete users).
If you're not logged in and try to access those pages, you get a 401 which is intercepted and redirects to the login page.
So, if I check the
client/app/account/account.js, I can see that there's a route for /settings with the authenticate option set to true, and that's fine.
Code:
.state('settings', {
url: '/settings',
templateUrl: 'app/account/settings/settings.html',
controller: 'SettingsCtrl',
authenticate: true
});
Problem is, in the
client/app/admin/admin.js route, there's no such thing, and I couldn't for the sake of god understand how it handles the admin authentication.
Code:
.state('admin', {
url: '/admin',
templateUrl: 'app/admin/admin.html',
controller: 'AdminCtrl'
});
Also, in the
client/app/admin/admin.controller.js controller, the
Auth factory is passed but not used (and apparently, the Auth.isAdmin() function is never used anywhere in the client side - but I may have missed it when searching).
Is there anymone familiar with this generator that could lend me a hand here?
Thanks!