Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide default login form when OIDC available #613

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"login_desc": "Sign In to your account",
"login_unauthorized": "Invalid username or password",
"login_forbidden": "This account is inactive or has been suspended",
"login_more_options": "More options",
"password_force_change": "Update Password",
"password_force_change_desc": "You need to change your password",
"password_change": "Change password",
Expand Down
18 changes: 14 additions & 4 deletions src/views/pages/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
v-model="input.username"
autofocus="true"
lazy="true"
v-show="showLoginForm"
/>
<b-validated-input-group-form-input
name="password"
Expand All @@ -32,22 +33,27 @@
autcomplete="currentpassword"
v-model="input.password"
lazy="true"
v-show="showLoginForm"
/>
<b-row>
<b-col cols="6">
<b-row style="margin-bottom: 1rem;">
<b-col cols="6" v-show="showLoginForm">
<b-button
variant="primary"
type="submit"
class="px-4"
>{{ $t('message.login') }}</b-button>
</b-col>
<b-col cols="6" v-show="oidcAvailable">
<b-button style="float: right" v-on:click="oidcLogin()">
<b-button :style="{ float: showLoginForm ? 'right' : 'none' }" v-on:click="oidcLogin()">
<span v-if="oidcCheckLoginButtonTextSetted()">{{ oidcLoginButtonText() }}</span>
<img alt="OpenID Logo" src="@/assets/img/openid-logo.svg" width="60px" v-else />
</b-button>
</b-col>
</b-row>
<b-link
v-show="oidcAvailable && !showLoginForm"
v-on:click="showLoginForm=true"
>{{ $t('message.login_more_options') }}</b-link>
</b-form>
</validation-observer>
</b-card-body>
Expand Down Expand Up @@ -102,7 +108,8 @@ export default {
response_type: this.$oidc.FLOW === "implicit" ? "token id_token" : "code",
scope: this.$oidc.SCOPE,
loadUserInfo: false
})
}),
showLoginForm: false
};
},
methods: {
Expand Down Expand Up @@ -187,6 +194,7 @@ export default {
this.checkOidcAvailability()
.then(oidcAvailable => {
this.oidcAvailable = oidcAvailable;
this.showLoginForm = !oidcAvailable;

if (!oidcAvailable) {
return;
Expand Down Expand Up @@ -235,6 +243,8 @@ export default {
});
})
.catch(err => {
// automatic fallback to login form when oidc availability check failed
this.showLoginForm = true;
this.$toastr.e(this.$t("message.oidc_availability_check_failed"));
});
}
Expand Down