Search posts, tags, users, and pages
Although not complete, here is a good start: dzone.com/articles/firebase-authentication-using-…
thank you, I'm finishing a demo put on github for more help and I share the link
Hello here is what I could already have github.com/patbi/seedocauth
but I would also like 1 - to redirect each type of users on his page 2 - Restrict access to the cat view for patients and visitors, but only accessible to doctors
my json
{ "patients": { "fname": "patrick", "lname": "isaac", "username": "patient1", "password": "hello", "year_of_birth": 1990, "email": "biyagapatrick@provider.com", "civility": [ "single", "married", "other" ], "phone_number": 698780156, "sex": [ "M", "F"], "srcImg": "img/pat.jpg", "electronic_notebook": { "name": "notebook1", "description": "description1", "content": "content1", "datecreation": 23-11-2018, "consultationdate": 23-11-2018 }, "userRole": { "bitMask": 2, "title": "patients" }, "tokens": [] }, "doctors": { "fname": "doctor1", "lname": "doctor1", "username": "doctor1", "password": "world", "year_of_birth": 1990, "age": 28, "email": "doctor1@provider.com", "phone_number": 698780156, "srcImg": "img/pat.jpg", "specialty": "surgeon-dentist", "hospital": { "name": "seedoc", "country": { "name": "cameroon", "region": { "name": "center", "city": { "name": "yaoundé", "street": { "name": "deido", }, }, }, }, }, "userRole": { "bitMask": 4, "title": "doctors" }, "tokens": [] }, "admin": { "username": "admin", "name": "admin", "password": "admin", "email": "admin@admin.admin", "userRole": { "bitMask": 5, "title": "admin" }, "tokens": [] } }
Do you have a running demo of this?
To route a user to his/her proper page after a successful login, you could do something like this
firebaseapp.controller('LoginController', ['$scope', 'Authentication', function($scope, Authentication) {
$scope.login = function() {
Authentication.login($scope.user).then(function(){
/**
* Assuming your Login function returns a promise (it might not at the moment)
*/
//CHECK TYPE OF USER HERE
//DEFINE TYPE HOWEVER YOU WANT
if(typeOfUser === "Admin"){
// ROUTE TO ADMIN PAGE
}
if(typeOfUser === "Guest"){
// ROUTE TO GUEST PAGE
}
});
}; // login function
/** Leaving out the rest of the functions for brevity ... */
}]); // LoginController
For restricted access, you can check user's role/permission at the state level and decide whether or not to allow them.
For more granular control, at the component level, you might want a directive that defines the allowed roles/permission combination and checks against the user's roles and permissions
This might help with that: github.com/mikemclin/angular-acl
Diego Bernal
Front-End Engineer