anthonygore / vue-router-user-roles Goto Github PK
View Code? Open in Web Editor NEWA Vue.js plugin that protects routes based on user roles. Add your own authentication.
License: MIT License
A Vue.js plugin that protects routes based on user roles. Add your own authentication.
License: MIT License
Hi, thanks for the great lib - real timesaver!
Is it possible to handle a user with multiple roles though as we have this requirement now?
vue: 2.6.4
vue-router: ^3.0.2
Out of the box
Setup access per documentation. Notice how when you have a protected route, it will flash before redirecting when access is not allowed.
read me part is missing.
Correct the read me part. Because npm package name is missing.
Feature ideas:
$user.hasAccess({ name: "routename" })
. This could be useful for conditionally displaying links depending on access.$user.set({...}, { redirect: false })
. Stop the page from automatically redirect when setting a user.Other:
Just seen this, looks like a great project!
I have this login flow using Amazon Cognito for the user login, but I also want to load site data when the site first loads, and user data after login or site reload (when there will be an auth token in local storage, but no user data).
I'm pretty sure it's my final flow.
You think it's doable with your plugin?
Vue -- 2.5.21
Vue Router -- 3.0.2
Out of the box
Setup access per documentation. Notice how when you have a protected route, it will flash before redirecting when access is not allowed.
Protected content will not be shown during access validation. Should most likely tie into VueRouter's navigation guards logic (ie beforeEach
) to bring validation higher up the chain.
Protected content is appearing on screen before access validation is performed and executed.
Thanks for this library - it is very useful. One feature request please:
Handle dynamic routes. My app requires no logins, because it's using Windows Auth and AD. I have a Vue component that handles errors, which takes a route parameter for the error code, e.g. for unauthorized user I would pass 403 as the code for Forbidden, and the page would display something specific relating to that issue (want to request access? blah blah):
{
role: "guest",
access: false,
redirect: "oops/403"
}
But it seems this does not work.
Your consideration would be much appreciated.
Would be great for TS users
package.json
has wrong module file "module": "dist/vue-router-user-roles.esm.js",
, that file doesn't exists
vue 2.6.14
vite 2.7.12
vue-router-user-roles 0.1.92
run yarn dev
No errors
Vite get error message
[plugin:vite:import-analysis] Failed to resolve entry for package "vue-router-user-roles". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "vue-router-user-roles". The package may have incorrect main/module/exports specified in its package.json.
First off, sorry for opening this issue for this, but I didn't see a way to mention this other wise.
Why is there a -D appended in the installation instructions? I understand -D flags for installations in dev-dependencies, but I would like this functionality to be available in production as well. Am I missing something?
I've just implemented this library on my first apollo/vue project ๐ฅ
I love the way you thinked your lib <3 but still have a question! And I think I'll not be the unique one with this question.
After login an user and provide his payload on the $user what's your recommendation to keep the user logged in ($user hydrated) also with browser refresh ?
I've thinked to keep my user's JWT's token on the localStorage and at each refresh just query my API to verify the JWT and re-populate my data on $user.
Another practice or maybe a good practice ?? ๐
PS : I can probably contributing to your documentation to add this point. It can be helpfull for other developers who want to implement your lib.
Cheers <3
Hi @anthonygore I just want to find out how this will be used with Nuxt.js
lost role property after reload page, and how use role, if I want not one ROLE?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.