Fix login

This commit is contained in:
Dane Everitt 2018-07-15 16:57:00 -07:00
parent ca27346e49
commit 4c4f6d3afe
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 7 additions and 41 deletions

View file

@ -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 },
});
});
}

View file

@ -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,

View file

@ -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: [],

View file

@ -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;
}
}
};