Oidc: Improve UX #782
This commit is contained in:
parent
31cdbec95c
commit
1ec9fc89a9
2 changed files with 23 additions and 15 deletions
|
@ -132,17 +132,25 @@ export default {
|
|||
).catch(() => this.loading = false);
|
||||
},
|
||||
loginExternal() {
|
||||
let popup = window.open('api/v1/auth/external', "external-login");
|
||||
window.localStorage.removeItem('auth_error');
|
||||
const onstorage = window.onstorage;
|
||||
const cleanup = () => {
|
||||
window.localStorage.removeItem('config');
|
||||
const c = this.$config.values;
|
||||
this.loading = true;
|
||||
axios.get(c.oidc,{ timeout: 3000}).then(response => {
|
||||
let popup = window.open('api/v1/auth/external', "external-login");
|
||||
window.localStorage.removeItem('auth_error');
|
||||
window.onstorage = onstorage;
|
||||
popup.close();
|
||||
};
|
||||
|
||||
window.onstorage = this.onExternalLogin(cleanup);
|
||||
const onstorage = window.onstorage;
|
||||
const cleanup = () => {
|
||||
window.localStorage.removeItem('config');
|
||||
window.localStorage.removeItem('auth_error');
|
||||
window.onstorage = onstorage;
|
||||
popup.close();
|
||||
};
|
||||
window.onstorage = this.onExternalLogin(cleanup);
|
||||
}).catch(error => {
|
||||
if (c.debug) console.log(error);
|
||||
Notify.error(`Couldn't connect to OpenID Connect Provider. ${error}`);
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
onExternalLogin(cleanup, redirect) {
|
||||
return () => {
|
||||
|
|
|
@ -25,11 +25,11 @@ func AuthEndpoints(router *gin.RouterGroup) {
|
|||
|
||||
router.GET("/auth/external", func(c *gin.Context) {
|
||||
openIdConnect, _ := service.Oidc()
|
||||
if err := openIdConnect.IsAvailable(); err != nil {
|
||||
c.Error(err)
|
||||
callbackError(c, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
//if err := openIdConnect.IsAvailable(); err != nil {
|
||||
// c.Error(err)
|
||||
// callbackError(c, err.Error(), http.StatusInternalServerError)
|
||||
// return
|
||||
//}
|
||||
|
||||
handle := openIdConnect.AuthUrlHandler()
|
||||
handle(c.Writer, c.Request)
|
||||
|
|
Loading…
Add table
Reference in a new issue