Merge pull request #5 from askotx/appserv

Appserv
This commit is contained in:
Juan Carlos Ruvalcaba 2021-05-28 18:11:30 -07:00 committed by GitHub
commit e43d4b50b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 844 additions and 556 deletions

1341
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,41 +30,41 @@
"axios": "^0.21.1",
"crypto-js": "^4.0.0",
"dom7": "^3.0.0",
"framework7": "^6.0.16",
"framework7": "^6.0.18",
"framework7-icons": "^4.0.2",
"localforage": "^1.9.0",
"skeleton-elements": "^3.3.0",
"swiper": "^6.5.7"
"swiper": "^6.6.2"
},
"devDependencies": {
"@babel/core": "^7.13.15",
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.13.15",
"@babel/core": "^7.14.3",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@babel/preset-react": "^7.13.13",
"@babel/runtime": "^7.13.10",
"@babel/runtime": "^7.14.0",
"babel-loader": "^8.2.2",
"chalk": "^4.1.0",
"concurrently": "^6.0.2",
"copy-webpack-plugin": "^8.1.1",
"chalk": "^4.1.1",
"concurrently": "^6.2.0",
"copy-webpack-plugin": "^9.0.0",
"cpy-cli": "^3.1.1",
"cross-env": "^7.0.3",
"css-loader": "^5.2.4",
"css-minimizer-webpack-plugin": "^2.0.0",
"css-loader": "^5.2.6",
"css-minimizer-webpack-plugin": "^3.0.0",
"file-loader": "^6.2.0",
"framework7-loader": "^3.0.2",
"html-webpack-plugin": "^5.3.1",
"less": "^4.1.1",
"less-loader": "^8.1.1",
"mini-css-extract-plugin": "^1.5.0",
"less-loader": "^9.0.0",
"mini-css-extract-plugin": "^1.6.0",
"ora": "^5.4.0",
"postcss-loader": "^5.2.0",
"postcss-loader": "^5.3.0",
"postcss-preset-env": "^6.7.0",
"rimraf": "^3.0.2",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.1",
"terser-webpack-plugin": "^5.1.2",
"url-loader": "^4.1.1",
"webpack": "^5.34.0",
"webpack-cli": "^4.6.0",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^3.11.2",
"workbox-webpack-plugin": "^6.1.5"
}

View File

@ -7,26 +7,30 @@ const user = createStore({
token: '',
user: {},
roles: [],
location: {},
},
actions: {
async setBasicData({ dispatch }, { token, user, roles }){
async setBasicData({ dispatch }, { token, user, roles, location }){
await localForage.setItem('user', user);
await localForage.setItem('token', token);
await localForage.setItem('roles', roles);
dispatch('auth_success', { token, user, roles });
await localForage.setItem('location', location);
dispatch('auth_success', { token, user, roles, location });
},
async getBasicData({ dispatch }){
const result = {
user: await localForage.getItem('user'),
token: await localForage.getItem('token'),
roles: await localForage.getItem('roles'),
location: await localForage.getItem('location'),
}
dispatch('auth_success', result);
},
async clearBasicData(){
await localForage.removeItem('user');
await localForage.removeItem('token');
await localForage.removeItem('roles');
await localForage.deleteItem('user');
await localForage.deleteItem('token');
await localForage.deleteItem('roles');
await localForage.deleteItem('location');
},
async checkData({ dispatch }){
let token = await localForage.getItem('token');
@ -44,9 +48,11 @@ const user = createStore({
delete response.data.token;
delete response.data.roles;
delete response.data.location;
return response;
} catch (error) {
}
catch (error) {
dispatch('auth_error');
await clearBasicData();
throw new error;
@ -63,15 +69,17 @@ const user = createStore({
state.token = '';
state.user = {};
state.roles = [];
state.location = {};
},
auth_request({ state }){
state.status = 'loading';
},
auth_success({ state }, { token, user, roles }){
auth_success({ state }, { token, user, roles, location }){
state.status = 'success';
state.token = token;
state.user = user;
state.roles = roles;
state.location = location;
},
auth_error({ state }){
state.status = 'error'
@ -91,6 +99,9 @@ const user = createStore({
roles({ state }){
return state.roles;
},
location({ state }){
return state.location
},
displayName({ state }){
return state.user;
}