From 4c4f6d3afe6d059bca885e61fd8bf4cfb13bbafd Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 15 Jul 2018 16:57:00 -0700 Subject: [PATCH] Fix login --- resources/assets/scripts/store/index.js | 10 +++--- .../assets/scripts/store/modules/auth.js | 2 +- .../assets/scripts/store/modules/server.js | 2 +- .../assets/scripts/store/modules/user.js | 34 ------------------- 4 files changed, 7 insertions(+), 41 deletions(-) delete mode 100644 resources/assets/scripts/store/modules/user.js diff --git a/resources/assets/scripts/store/index.js b/resources/assets/scripts/store/index.js index ca8a44630..1725169b7 100644 --- a/resources/assets/scripts/store/index.js +++ b/resources/assets/scripts/store/index.js @@ -1,22 +1,22 @@ import Vue from 'vue'; import Vuex from 'vuex'; -import { serverModule } from "./modules/server"; -import { userModule } from './modules/user'; -import { authModule } from "./modules/auth"; +import server from "./modules/server"; +import auth from "./modules/auth"; Vue.use(Vuex); const store = new Vuex.Store({ strict: process.env.NODE_ENV !== 'production', - modules: { userModule, serverModule, authModule }, + modules: { auth, server }, }); if (module.hot) { module.hot.accept(['./modules/auth'], () => { const newAuthModule = require('./modules/auth').default; + const newServerModule = require('./modules/server').default; store.hotUpdate({ - modules: { newAuthModule }, + modules: { newAuthModule, newServerModule }, }); }); } diff --git a/resources/assets/scripts/store/modules/auth.js b/resources/assets/scripts/store/modules/auth.js index 7e095723a..24c5f3028 100644 --- a/resources/assets/scripts/store/modules/auth.js +++ b/resources/assets/scripts/store/modules/auth.js @@ -2,7 +2,7 @@ import User from './../../models/user'; const route = require('./../../../../../vendor/tightenco/ziggy/src/js/route').default; -export const authModule = { +export default { namespaced: true, state: { user: typeof window.PterodactylUser === 'object' ? new User(window.PterodactylUser) : null, diff --git a/resources/assets/scripts/store/modules/server.js b/resources/assets/scripts/store/modules/server.js index 8be6f0463..32026896f 100644 --- a/resources/assets/scripts/store/modules/server.js +++ b/resources/assets/scripts/store/modules/server.js @@ -1,7 +1,7 @@ import LoadingState from '../../models/loadingStates'; import route from '../../../../../vendor/tightenco/ziggy/src/js/route'; -export const serverModule = { +export default { state: { servers: {}, serverIDs: [], diff --git a/resources/assets/scripts/store/modules/user.js b/resources/assets/scripts/store/modules/user.js deleted file mode 100644 index 091472075..000000000 --- a/resources/assets/scripts/store/modules/user.js +++ /dev/null @@ -1,34 +0,0 @@ -import {User} from "../../models/user"; - -export const userModule = { - state: { - user: null, - }, - actions: { - login ({ commit }) { - commit('setUser', User.fromJWT(localStorage.getItem('token'))); - }, - logout ({ commit }) { - commit('unsetUser'); - } - }, - getters: { - getCurrentUser: function (state) { - return state.user; - }, - }, - mutations: { - /** - * Log in a user and store them in vuex using the local storage token. - * - * @param state - * @param user - */ - setUser: function (state, user) { - state.user = user; - }, - unsetUser: function (state) { - state.user = null; - } - } -};