-
-
-
-
+
+
+
+
Login or Register
+
{{ errorMsg }}
-
+
{{ $t('You are already logged in!') }}
-
{{$t('logout')}}
+
{{$t('Redirecting you to')}} {{redirectTarget}} {{$t('in')}} {{redirectTime}} {{$t('seconds')}}.
+
{{$t('logout')}}
@@ -64,6 +65,9 @@
email: '',
password: '',
errorMsg: '',
+ redirectMsg: '',
+ redirectTarget: 'profile',
+ redirectTime: 5,
loginProviders: [],
};
},
@@ -79,6 +83,10 @@
oidc_login() {
this.$store.dispatch('oidc_login', '\\oidc_login_redirection');
},
+ logout() {
+ this.$store.dispatch('logout', {revokeRefreshToken: true});
+ this.$router.push({name: 'home'});
+ },
},
mounted() {
// this.$parent.$data.isLoading = true;
@@ -104,6 +112,22 @@
this.$cookies.remove('tokens');
}
this.$log.debug(this.$cookies.keys());
+
+ this.$nextTick(() => {
+ if (this.authenticated) {
+ if (this.$route.query.redirectionTarget) {
+ this.redirectTarget = this.$route.query.redirectionTarget;
+ }
+ let interval = window.setInterval(() => {
+ console.log(this.redirectTime);
+ this.redirectTime = this.redirectTime - 1;
+ if (this.redirectTime < 0) {
+ clearInterval(interval);
+ this.$router.push({name: this.redirectTarget});
+ }
+ }, 1000);
+ }
+ });
},
beforeDestroy() {
EventBus.$off('failedRegistering');
diff --git a/src/store.ts b/src/store.ts
index 1118f0c..a8677a6 100644
--- a/src/store.ts
+++ b/src/store.ts
@@ -14,7 +14,7 @@ import {
postNewSurvey,
authenticate,
register,
- oidc_login, fetchUsers, getFreshToken, fetchProfile, fetchUserGroups,
+ oidc_login, fetchUsers, getFreshToken, fetchProfile, fetchUserGroups, revokeRefreshKey,
} from '@/api';
import {isValidJwt, EventBus} from '@/utils';
@@ -184,6 +184,17 @@ const actions = {
EventBus.$emit('failedAuthentication', error);
});
},
+ logout(context: any, revokeRefreshToken: any) {
+ context.commit('setTokens', {tokens: {access_token: '', refresh_token: ''}});
+ if(revokeRefreshToken){
+ return revokeRefreshKey(context.state.access_token)
+ .catch((error) => {
+ Vue.$log.warn('Error Authenticating (Could not revoke refresh token): ', error);
+ EventBus.$emit('failedRevokingRefreshToken', error);
+ });
+ }
+ //this.clearAll();
+ },
oidc_login(context: any, redirectionUrl: any) {
// context.commit('setUserData', { userData });
return oidc_login(redirectionUrl)