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.$toast.success(this.$t('login.success'))
this.$emit('success') this.$emit('success')
} catch (err) { } 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) { toggleShowPassword(event) {

View File

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

View File

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

View File

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