Hello again developer pal!, if you have come across this repo on purpose great! thanks for reading, otherwise, maybe you want to take a look at its predecesor login-vuex-firebase, and if you have a chance, perhaps you can take a look at the post created for it right here.
Anyway, let me tell you that this repo is the next step to the authentication, yes, this is for the authorization; it is a simple one using an assigned role for some users by email. I can bet that there are several ways to do it, I wont go to deep cause:
- Want to give you a sample, you are allowed to fork and reimplement as much as you want/require.
- These are my first posts so I am taking it easy.
- Any feedback is more than welcome as a PR or thread in the post(I'll be adding the link as soon as I publish it)
If you checked my aforementioned code and post, you remember we ended up having a functional authentication like this:
So far so good!, but what would happen if you want to limitate the access to the users?, depending whether dealing with an admin
or a player
(yeap these are the couple roles we could have for this case).
We want to have a way to allow certain views to the admin
and some others to the player
, something like this:
Allow the access as an administrator to a dashboard page, but forbid to access other users page
Allow the access as a player to a landing page, but forbid to access admin pages
-
Take an overview of roles-vuex-firebase repo
-
Clone the repo
git clone git@github.com:crisarji/roles-vuex-firebase.git
-
Install NPM packages
npm install
-
Enter your API from Firebase in
firebase.js
const firebaseConfig = { apiKey: 'YOUR_API_KEY', authDomain: 'YOUR_AUTH_DOMAIN', databaseURL: 'YOUR_DATABASE_URL', projectId: 'YOUR_PROJECT_ID', storageBucket: 'YOUR_STORAGE_BUCKET', messagingSenderId: 'YOUR_MESSAGING_SENDER_ID', appId: "YOUR_APP_ID", measurementId: "YOUR_MEASUREMENT_ID" };
- Run the app
npm run serve
Here you can find the list of dependencies
used for this project:
In addition for the functions
section:
This repo is released under the under terms of the MIT License.