feat: Authenticate by SSO tokens (#1439)
Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
</h2>
|
||||
</div>
|
||||
<div class="row align-center">
|
||||
<div class="small-12 medium-4 column">
|
||||
<div v-if="!email" class="small-12 medium-4 column">
|
||||
<form class="login-box column align-self-top" @submit.prevent="login()">
|
||||
<div class="column log-in-form">
|
||||
<label :class="{ error: $v.credentials.email.$error }">
|
||||
@@ -47,7 +47,6 @@
|
||||
button-class="large expanded"
|
||||
>
|
||||
</woot-submit-button>
|
||||
<!-- <input type="submit" class="button " v-on:click.prevent="login()" v-bind:value="" > -->
|
||||
</div>
|
||||
</form>
|
||||
<div class="column text-center sigin__footer">
|
||||
@@ -63,13 +62,12 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<woot-spinner v-else size="" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/* global bus */
|
||||
|
||||
import { required, email } from 'vuelidate/lib/validators';
|
||||
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
|
||||
import WootSubmitButton from '../../components/buttons/FormSubmitButton';
|
||||
@@ -80,6 +78,12 @@ export default {
|
||||
WootSubmitButton,
|
||||
},
|
||||
mixins: [globalConfigMixin],
|
||||
props: {
|
||||
ssoAuthToken: { type: String, default: '' },
|
||||
redirectUrl: { type: String, default: '' },
|
||||
config: { type: String, default: '' },
|
||||
email: { type: String, default: '' },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// We need to initialize the component with any
|
||||
@@ -111,6 +115,11 @@ export default {
|
||||
globalConfig: 'globalConfig/get',
|
||||
}),
|
||||
},
|
||||
created() {
|
||||
if (this.ssoAuthToken) {
|
||||
this.login();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showAlert(message) {
|
||||
// Reset loading, current selected agent
|
||||
@@ -124,8 +133,9 @@ export default {
|
||||
login() {
|
||||
this.loginApi.showLoading = true;
|
||||
const credentials = {
|
||||
email: this.credentials.email,
|
||||
email: this.email ? this.email : this.credentials.email,
|
||||
password: this.credentials.password,
|
||||
sso_auth_token: this.ssoAuthToken,
|
||||
};
|
||||
this.$store
|
||||
.dispatch('login', credentials)
|
||||
@@ -133,6 +143,11 @@ export default {
|
||||
this.showAlert(this.$t('LOGIN.API.SUCCESS_MESSAGE'));
|
||||
})
|
||||
.catch(response => {
|
||||
// Reset URL Params if the authenication is invalid
|
||||
if (this.email) {
|
||||
window.location = '/app/login';
|
||||
}
|
||||
|
||||
if (response && response.status === 401) {
|
||||
this.showAlert(this.$t('LOGIN.API.UNAUTH'));
|
||||
return;
|
||||
|
||||
@@ -7,6 +7,12 @@ export default {
|
||||
path: frontendURL('login'),
|
||||
name: 'login',
|
||||
component: Login,
|
||||
props: route => ({
|
||||
config: route.query.config,
|
||||
email: route.query.email,
|
||||
ssoAuthToken: route.query.sso_auth_token,
|
||||
redirectUrl: route.query.route_url,
|
||||
}),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user