mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 17:01:07 +03:30
new Changes
This commit is contained in:
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
import { UserService } from '@/services/auth/user.service'
|
||||
export default {
|
||||
async info({ commit }) {
|
||||
const info = await UserService.getInfo();
|
||||
commit("setInfo", info);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
// https://vuex.vuejs.org/en/getters.html
|
||||
|
||||
export default {
|
||||
//
|
||||
}
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Vuex
|
||||
*
|
||||
* @library
|
||||
*
|
||||
* https://vuex.vuejs.org/en/
|
||||
*/
|
||||
|
||||
// Lib imports
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
// Store functionality
|
||||
import actions from './actions'
|
||||
import getters from './getters'
|
||||
import modules from './modules'
|
||||
import mutations from './mutations'
|
||||
import state from './state'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
// Create a new store
|
||||
const store = new Vuex.Store({
|
||||
actions,
|
||||
getters,
|
||||
modules,
|
||||
mutations,
|
||||
state
|
||||
})
|
||||
|
||||
export default store
|
||||
@@ -1,8 +0,0 @@
|
||||
import { set, toggle } from '@/utils/vuex'
|
||||
|
||||
export default {
|
||||
setDrawer: set('drawer'),
|
||||
setImage: set('image'),
|
||||
setColor: set('color'),
|
||||
toggleDrawer: toggle('drawer')
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
drawer: null,
|
||||
color: 'WM-CyanBlueGradient-BG',
|
||||
// image: 'https://demos.creative-tim.com/vue-material-dashboard/img/sidebar-2.32103624.jpg'
|
||||
}
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
import { UserService, AuthenticationError, ApiService, TokenService } from '@/services'
|
||||
import router from '@/router'
|
||||
import { urls } from '@/config/urls'
|
||||
|
||||
export default {
|
||||
async login({ commit, dispatch }, {cell_number, password}) {
|
||||
commit('loginRequest');
|
||||
try {
|
||||
const response = await UserService.login(cell_number, password);
|
||||
commit('loginSuccess', response.data.access_token);
|
||||
// Redirect the user to the page he first tried to visit or to the home view
|
||||
router.push(router.history.current.query.redirect || '/');
|
||||
|
||||
dispatch('info', {}, {root : true});
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
if (e instanceof AuthenticationError) {
|
||||
commit('loginError', {errorCode: e.errorCode, errorMessage: e.message})
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
async forgotPassword({commit}, {form}) {
|
||||
var result = await ApiService.post(urls.forgotPassword, form);
|
||||
if(result && result.status == 200) {
|
||||
commit('modal/changeCurrentModal', { modal: "modal-auth-verify-code" }, {root: true});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async verifyCodeSMS({commit, dispatch}, {form}) {
|
||||
var response = await ApiService.post(urls.sendVerifyCode, form);
|
||||
if(response && response.status == 200 && response.data.access_token) {
|
||||
TokenService.saveToken(response.data.access_token);
|
||||
TokenService.saveRefreshToken(response.data.refresh_token);
|
||||
ApiService.setAuthHeader();
|
||||
commit('loginSuccess', response.data.access_token);
|
||||
commit('modal/changeCurrentModal', { modal: "modal-auth-change-password" }, {root: true});
|
||||
dispatch('info', {}, {root : true});
|
||||
}
|
||||
},
|
||||
|
||||
async changePassword({commit}, {form}) {
|
||||
var response = await ApiService.post(urls.changePassword, form);
|
||||
if(response && response.status == 200 ) {
|
||||
commit('modal/closeModal', {}, {root: true});
|
||||
router.push({ name: `Dashboard` });
|
||||
}
|
||||
},
|
||||
|
||||
async logout({ commit }) {
|
||||
await UserService.logout();
|
||||
commit('logoutSuccess')
|
||||
router.push('/login')
|
||||
},
|
||||
|
||||
refreshToken({ commit, state }) {
|
||||
// If this is the first time the refreshToken has been called, make a request
|
||||
// otherwise return the same promise to the caller
|
||||
if(!state.refreshTokenPromise) {
|
||||
const p = UserService.refreshToken()
|
||||
commit('refreshTokenPromise', p)
|
||||
|
||||
// Wait for the UserService.refreshToken() to resolve. On success set the token and clear promise
|
||||
// Clear the promise on error as well.
|
||||
p.then(
|
||||
response => {
|
||||
commit('refreshTokenPromise', null)
|
||||
commit('loginSuccess', response)
|
||||
},
|
||||
error => {
|
||||
commit('refreshTokenPromise', null)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return state.refreshTokenPromise
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
export default {
|
||||
loggedIn: (state) => {
|
||||
return state.accessToken ? true : false
|
||||
},
|
||||
|
||||
authenticationErrorCode: (state) => {
|
||||
return state.authenticationErrorCode
|
||||
},
|
||||
|
||||
authenticationError: (state) => {
|
||||
return state.authenticationError
|
||||
},
|
||||
|
||||
authenticating: (state) => {
|
||||
return state.authenticating
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
export default {
|
||||
loginRequest(state) {
|
||||
state.authenticating = true;
|
||||
state.authenticationError = ''
|
||||
state.authenticationErrorCode = 0
|
||||
},
|
||||
|
||||
loginSuccess(state, accessToken) {
|
||||
state.accessToken = accessToken;
|
||||
state.authenticating = false;
|
||||
},
|
||||
|
||||
loginError(state, {errorCode, errorMessage}) {
|
||||
state.authenticating = false
|
||||
state.authenticationErrorCode = errorCode
|
||||
state.authenticationError = errorMessage
|
||||
},
|
||||
|
||||
logoutSuccess(state) {
|
||||
state.accessToken = ''
|
||||
},
|
||||
|
||||
|
||||
refreshTokenPromise(state, promise) {
|
||||
state.refreshTokenPromise = promise
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { TokenService } from '@/services/auth/storage.service'
|
||||
|
||||
export default {
|
||||
authenticating: false,
|
||||
accessToken: TokenService.getToken(),
|
||||
authenticationErrorCode: 0,
|
||||
authenticationError: '',
|
||||
refreshTokenPromise: null // Holds the promise of the refresh token
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// https://vuex.vuejs.org/en/modules.html
|
||||
|
||||
const requireModule = require.context('.', true, /\.js$/)
|
||||
const modules = {}
|
||||
|
||||
requireModule.keys().forEach(fileName => {
|
||||
if (fileName === './index.js') return
|
||||
|
||||
// Replace ./ and .js
|
||||
const path = fileName.replace(/(\.\/|\.js)/g, '')
|
||||
const [moduleName, imported] = path.split('/')
|
||||
if (!modules[moduleName]) {
|
||||
modules[moduleName] = {
|
||||
namespaced: true
|
||||
}
|
||||
}
|
||||
|
||||
modules[moduleName][imported] = requireModule(fileName).default
|
||||
})
|
||||
|
||||
export default modules
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
export default {
|
||||
getCurrentModal: (state) => {
|
||||
return state.currentModal.name
|
||||
},
|
||||
getModalProperties: (state) => {
|
||||
return state.currentModal.properties;
|
||||
},
|
||||
getModalResult: (state) => {
|
||||
return state.currentModal.result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
export default {
|
||||
changeCurrentModal: (state, data) => {
|
||||
state.result = '';
|
||||
state.currentModal.name = data.modal;
|
||||
if (data.properties) {
|
||||
state.currentModal.properties = data.properties;
|
||||
}
|
||||
},
|
||||
setResultModal: (state, data) => {
|
||||
state.currentModal.result = data;
|
||||
},
|
||||
closeModal: state => {
|
||||
state.currentModal.name = "";
|
||||
state.currentModal.properties = {};
|
||||
}
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
export default {
|
||||
currentModal: {
|
||||
name: '',
|
||||
properties: {},
|
||||
result: {}
|
||||
},
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
export default {
|
||||
setInfo: (state, info) => {
|
||||
if(info.user) {
|
||||
state.user = info.user;
|
||||
}
|
||||
if(info.roles) {
|
||||
state.roles = info.roles;
|
||||
}
|
||||
}
|
||||
};
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
export default {
|
||||
user : {},
|
||||
}
|
||||
Reference in New Issue
Block a user