checks that a cookie exists after login. If not, throw an error saying that no cookie can be set

This commit is contained in:
Moriz Wahl 2020-12-18 11:31:16 +01:00
parent 4b0893c1df
commit c405e008e4
4 changed files with 13 additions and 1 deletions

View File

@ -91,7 +91,11 @@ export default {
this.$toast.success(this.$t('login.success'))
this.$emit('success')
} catch (err) {
this.$toast.error(this.$t('login.failure'))
if (err.message === 'Error: no-cookie') {
this.$toast.error(this.$t('login.no-cookie'))
} else {
this.$toast.error(this.$t('login.failure'))
}
}
},
toggleShowPassword(event) {

View File

@ -315,6 +315,7 @@
"moreInfo": "Was ist {APPLICATION_NAME}?",
"moreInfoHint": "zur Präsentationsseite",
"no-account": "Du hast noch kein Benutzerkonto?",
"no-cookie": "Es kann kein Cookie angelegt werden. Du must Cookies akzeptieren.",
"password": "Dein Passwort",
"register": "Benutzerkonto erstellen",
"success": "Du bist eingeloggt!"

View File

@ -315,6 +315,7 @@
"moreInfo": "What is {APPLICATION_NAME}?",
"moreInfoHint": "to the presentation page",
"no-account": "Don't have an account?",
"no-cookie": "No cookie can be set. You must accept cookies.",
"password": "Your Password",
"register": "Sign up",
"success": "You are logged in!"

View File

@ -1,6 +1,9 @@
import gql from 'graphql-tag'
import { VERSION } from '~/constants/terms-and-conditions-version.js'
import { currentUserQuery } from '~/graphql/User'
import Cookie from 'universal-cookie'
const cookies = new Cookie()
export const state = () => {
return {
@ -99,6 +102,9 @@ export const actions = {
await this.app.$apolloHelpers.onLogin(login)
commit('SET_TOKEN', login)
await dispatch('fetchCurrentUser')
if (cookies.get('ocelot-social-token') === undefined) {
throw new Error('no-cookie')
}
} catch (err) {
throw new Error(err)
} finally {