Role based authentication with firebase and angularjs

半腔热情 提交于 2019-12-24 04:59:09

问题


I am using email/password authentication via Firebase, so currently I only have authenticated user and non-authenticated user. But for the app, I would like to have admin, moderator, user and guest four different kinds of role.

I did some research, but could not find any existing example or logic to do so. Here are my initial thoughs, but not sure if it is feasible. Basically two steps:

  • Create a table in firebase called User, while Firebase record the email/password, I also push the data(email/password), and role information to the table.
  • In the route, check if the user has the appropriate role to access the certain page

Any other better way to do it? Any idea would be appreciated!


回答1:


I had similar issue while working with role based authorization. I followed same pattern of saving users role and then retriving it when needed. If you are using ui-router for routes then probably you can use angular-permission module which works on the same concept and is easy to use.

You can find that module here: https://github.com/Narzerus/angular-permission



来源:https://stackoverflow.com/questions/32217210/role-based-authentication-with-firebase-and-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!