alonbardavid / visor Goto Github PK
View Code? Open in Web Editor NEWauthentication and authorization module for angular apps
License: MIT License
authentication and authorization module for angular apps
License: MIT License
Again, thanks a lot for fixing the previous issue. It even resolved an other issue we had. Now it fulfills all requirements we have!
Might it be possible to pump the newest version to npm. The current npm version includes a console.log in the ui router code...
get permissions
Thanks!
Also it would be handy if we could change the next url manually whenever we needed, so please add it to the provider with:
visor.addNextToUrl = function addNextToUrl(restrictedUrl){
$location.search('next', restrictedUrl);
};
split from #14.
Might it be possible to package visor as NPM-Package.
I am happy to provide a PR.
It is misaligned parentheses, inconsistent use of brackets and semicolons etc.
This makes it harder to contribute to the codebase.
Hello
I don't understand the idea to launch the visorProvider.authenticate when the page is loaded.
Specially with your example with an $http promise.
Could you please explain more the concept ?
thanks
if the path that was redirected to login screen is is http://www.example.com/#/mypage
the 'next' param is '/mypage' instead of '/#/mypage'
AngularJS projects migrating to UI-Router V1 must use the stateEvents.js polyfill in order for angular-visor to continue working, see: #18
For UI-Router projects upgrading from AngularJS to Angular, this involves switching from https://www.npmjs.com/package/@uirouter/angularjs to https://www.npmjs.com/package/@uirouter/angular-hybrid for ngUpgrade support.
However, while the 'next' query string parameter works correctly using ui-router/angularjs + stateEvents.js polyfill, ui-router/angular-hybrid + stateEvents.js polyfill causes the 'next' query string parameter to behave incorrectly.
ui-router/angularjs trace:
Transition #0-0: <- Rejected "Transition#0( ''{} -> 'dashboard.phase'{} )", reason: Transition Rejection($id: 0 type: 3, message: The transition has been aborted, detail: Hook aborted transition)
Transition #1-0: Started -> "Transition#1( ''{} -> 'user.signin'{"next":"/dashboard/phase"} )"
Transition #1-0: <- Success "Transition#1( ''{} -> 'user.signin'{"next":"/dashboard/phase"} )", final state: user.signin
ui-router/angular-hybrid trace:
Transition #0-0: <- Rejected "Transition#0( ''{} -> 'dashboard.phase'{} )", reason: Transition Rejection($id: 0 type: 3, message: The transition has been aborted, detail: Hook aborted transition)
Transition #1-0: <- Rejected "Transition#1( ''{} -> 'dashboard.phase'{} )", reason: Transition Rejection($id: 1 type: 3, message: The transition has been aborted, detail: Hook aborted transition)
Transition #2-0: Started -> "Transition#2( ''{} -> 'user.signin'{"next":"/dashboard/phase"} )"
Transition #2-0: <- Success "Transition#2( ''{} -> 'user.signin'{"next":"/dashboard/phase"} )", final state: user.signin
Transition #3-0: Started -> "Transition#3( 'user.signin'{"next":"/dashboard/phase"} -> 'user.signin'{"next":"/user/signin?next=%2Fdashboard%2Fphase"} )"
Transition #3-0: <- Success "Transition#3( 'user.signin'{"next":"/dashboard/phase"} -> 'user.signin'{"next":"/user/signin?next=%2Fdashboard%2Fphase"} )", final state: user.signin
Hello
The next parameter is always filled with the url where I came from, and not the restricted url ?
I am using the ui-router version.
any idea ?
The current function has a bad behavior, which I caused.
I had to use this function to change the default next url to whatever I needed, but if the url has a next parameter then it starts replacing (which actually works), but it leaves a comma (,) in the url 😞
The correct behavior instead of replacing the url via regex is to use the built in $location.path()
and $location.search()
.
The method then should look like:
config.doOnNotAuthenticated = ["$location", "restrictedUrl", function ($location, restrictedUrl) {
$location.path(config.loginRoute).search('next', restrictedUrl);
}];
Also it would be handy if we could change the next url manually whenever we needed, so please add it to the provider with:
visor.addNextToUrl = function addNextToUrl(restrictedUrl){
$location.search('next', restrictedUrl);
};
With a traditional login form (with username and password and a login button), when we click the "Login" button, should we call the visorProvider.authenticate (if we declare a $http promise) or should we manage the $http in the controller of the login form ?
Do you have an example ?
Thanks again
Visor v0.1.2 doesn't work with AngularJS v1.6.4. It fails in method Visor.authenticate at line:
['finally'](function () {
Console log:
bundle.c3eb2f5….js:28906 Uncaught TypeError: $injector.invoke(...).then(...).finally is not a function
at Object.authenticate (bundle.c3eb2f5….js:28906)
at bundle.c3eb2f5….js:28989
at Object.invoke (bundle.c3eb2f5….js:34488)
at bundle.c3eb2f5….js:34290
at forEach (bundle.c3eb2f5….js:29888)
at createInjector (bundle.c3eb2f5….js:34290)
at doBootstrap (bundle.c3eb2f5….js:31399)
at bootstrap (bundle.c3eb2f5….js:31420)
at angularInit (bundle.c3eb2f5….js:31305)
at bundle.c3eb2f5….js:62852
authenticate @ bundle.c3eb2f5….js:28906
(anonymous) @ bundle.c3eb2f5….js:28989
invoke @ bundle.c3eb2f5….js:34488
(anonymous) @ bundle.c3eb2f5….js:34290
forEach @ bundle.c3eb2f5….js:29888
createInjector @ bundle.c3eb2f5….js:34290
doBootstrap @ bundle.c3eb2f5….js:31399
bootstrap @ bundle.c3eb2f5….js:31420
angularInit @ bundle.c3eb2f5….js:31305
(anonymous) @ bundle.c3eb2f5….js:62852
trigger @ bundle.c3eb2f5….js:32916
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.