Comments (3)
Hi there.
Firstly thank you for the example project. I have been playing with it and it integrates flawlessly with my IS4 implementation! 😃
What I want to do is add a new home page with a 'login' button. When a user clicks the login button, it instigates the implicit flow (exactly like the project) and they get directed to the 'home' page (
url/home
).I tried to:
- Start the flow by moving
mounted
logic into a function so I can call it programmatically - this did not work, as I suspect the mounted life cycle gets called multiple times and mapping a function to a 'login button' is not enoughI then tried:
- move the logic from
app.vue
into a new component i.e.login.vue
.- add login button to
app.vue
which links tologin.vue
(viarouter-link
) and leave the rest untouchedModify app.vue to have a link:
<template> <div> <div id="app"> <router-link to="/login">Login</router-link> <router-view/> </div> </div> </template>
Then in my routes:
{ path: "/login", name: "Login", component: Login }, { path: "/dashboard", name: "Home", component: Home }
Now I'm unsure on how to progress from here and I'm wondering (after a few attempts) if I am just overcomplicating things...
Is there a simple/obvious way to just have a login page which then kicks off the flow?
Thanks in advance 😄
you can try like this
<template> <div> <div v-if=signedIn> <router-view /> </div> <div v-else> <AnotherPage/> </div> </div> </template>
from vuejsoidcclient.
Ok I feel a bit silly... it was much simpler than I expected.
What caught me out was the method getSignedIn(){...}
. I didn't carefully look at that method, but I assumed it would return a boolean to determine if the user is signed in or not... however:
getSignedIn() {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function(user) {
if (user == null) {
self.signIn();
return resolve(false);
} else {
return resolve(true);
}
})
.catch(function(err) {
console.log(err);
return reject(err);
});
});
}
It is making a call to self.signIn();
, which is what was confusing me all along since I assumed the method was simply checking if the user was logged in. I guess the method should have been called getSignedInAndSignInIfNot
or something like that to make it obvious that the method does more than the name implies 😆
from vuejsoidcclient.
For those interested, I have a little demo project that achieved what I wanted
from vuejsoidcclient.
Related Issues (12)
- Silent Renew Frame window timed out HOT 18
- How to request Access Token after Authentication HOT 3
- UserInfo Endpoint not called HOT 4
- Próximas implementações HOT 2
- Projeto com pacotes obsoletos e com falhas de segurança HOT 1
- the img directory is unable to locate HOT 1
- Funcionamento no internet Explore 11 HOT 12
- silent renew control HOT 3
- How to use Multiple Roles HOT 2
- Acess Token
- UserManager.getUser: user not found in storage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuejsoidcclient.