Skip to content
Permalink
Browse files

Add logout endpoint option

  • Loading branch information...
hareku committed May 13, 2017
1 parent 0664db6 commit 4a843b63dbeee9853687b297f0d49bfd9f5e7e41
Showing with 6 additions and 3 deletions.
  1. +6 −3 modules/auth/store.js
@@ -5,7 +5,7 @@

import Cookie from 'cookie'
import Cookies from 'js-cookie'
import {setToken, $get, $post} from './axios' // Axios is a peer plugin dependency
import {setToken, $get, $post, $delete} from './axios' // Axios is a peer plugin dependency

const inBrowser = typeof window !== 'undefined'
const SSR = global.__VUE_SSR_CONTEXT__
@@ -105,12 +105,15 @@ function AuthStore (opts) {
})
},

logout (ctx) {
logout (ctx, {endpoint = '/auth/logout', appendToken = false}) {
// Unload user profile
ctx.commit('setUser', null)

// Create logout endpoint
const endpoint = endpoint + appendToken ? `/${ctx.state.token}` : ''

// Server side logout
return $get('/auth/logout').then(() => {
return $delete(endpoint).then(() => {
// Unset token
ctx.commit('setToken', null)
}).catch(() => {

0 comments on commit 4a843b6

Please sign in to comment.
You can’t perform that action at this time.