Commit 7784427b authored by Kittisak Maneewong's avatar Kittisak Maneewong

success auth

parent e7f4199a
...@@ -1294,6 +1294,14 @@ ...@@ -1294,6 +1294,14 @@
"integrity": "sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg==", "integrity": "sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg==",
"dev": true "dev": true
}, },
"async-validator": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-1.11.0.tgz",
"integrity": "sha512-3ROlrxLee6KB1aEj9eENBLB0pPCPCb+hc+aGify63HBHptq5FnEFNAQOAkhbx7xBlVh5XXi2w+QEecWpOdigpw==",
"requires": {
"babel-runtime": "6.x"
}
},
"atob": { "atob": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
...@@ -1391,6 +1399,27 @@ ...@@ -1391,6 +1399,27 @@
"object.omit": "^3.0.0" "object.omit": "^3.0.0"
} }
}, },
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
},
"dependencies": {
"core-js": {
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz",
"integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A=="
},
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
}
}
},
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
...@@ -1464,6 +1493,11 @@ ...@@ -1464,6 +1493,11 @@
"integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=",
"dev": true "dev": true
}, },
"batch-processor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/batch-processor/-/batch-processor-1.0.0.tgz",
"integrity": "sha1-dclcMrdI4IUNEMKxaPa9vpiRrOg="
},
"big.js": { "big.js": {
"version": "5.2.2", "version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
...@@ -2638,8 +2672,7 @@ ...@@ -2638,8 +2672,7 @@
"deepmerge": { "deepmerge": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz",
"integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==", "integrity": "sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA=="
"dev": true
}, },
"default-gateway": { "default-gateway": {
"version": "4.2.0", "version": "4.2.0",
...@@ -2901,6 +2934,14 @@ ...@@ -2901,6 +2934,14 @@
"integrity": "sha512-3mtqcAWa4HgG+Djh/oNXlPH0cOH6MmtwxN1nHSaReb9P0Vn51qYPqYwLeoSuAX9loU1wrOBhFbiX3CkeIxPfgg==", "integrity": "sha512-3mtqcAWa4HgG+Djh/oNXlPH0cOH6MmtwxN1nHSaReb9P0Vn51qYPqYwLeoSuAX9loU1wrOBhFbiX3CkeIxPfgg==",
"dev": true "dev": true
}, },
"element-resize-detector": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/element-resize-detector/-/element-resize-detector-1.2.0.tgz",
"integrity": "sha512-UmhNB8sIJVZeg56gEjgmMd6p37sCg8j8trVW0LZM7Wzv+kxQ5CnRHcgRKBTB/kFUSn3e7UP59kl2V2U8Du1hmg==",
"requires": {
"batch-processor": "1.0.0"
}
},
"elliptic": { "elliptic": {
"version": "6.4.1", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",
...@@ -3668,8 +3709,7 @@ ...@@ -3668,8 +3709,7 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
...@@ -3690,14 +3730,12 @@ ...@@ -3690,14 +3730,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
...@@ -3712,20 +3750,17 @@ ...@@ -3712,20 +3750,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
...@@ -3842,8 +3877,7 @@ ...@@ -3842,8 +3877,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
...@@ -3855,7 +3889,6 @@ ...@@ -3855,7 +3889,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
...@@ -3870,7 +3903,6 @@ ...@@ -3870,7 +3903,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
...@@ -3878,14 +3910,12 @@ ...@@ -3878,14 +3910,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
...@@ -3904,7 +3934,6 @@ ...@@ -3904,7 +3934,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
...@@ -3985,8 +4014,7 @@ ...@@ -3985,8 +4014,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
...@@ -3998,7 +4026,6 @@ ...@@ -3998,7 +4026,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
...@@ -4084,8 +4111,7 @@ ...@@ -4084,8 +4111,7 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
...@@ -4121,7 +4147,6 @@ ...@@ -4121,7 +4147,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
...@@ -4141,7 +4166,6 @@ ...@@ -4141,7 +4166,6 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
...@@ -4185,14 +4209,12 @@ ...@@ -4185,14 +4209,12 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
} }
} }
}, },
...@@ -5095,6 +5117,26 @@ ...@@ -5095,6 +5117,26 @@
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
"dev": true "dev": true
}, },
"iview": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/iview/-/iview-3.4.0.tgz",
"integrity": "sha512-MSqro+YxJ91MnxkAd4iR4VK9usEIX2+qE4W5qwnbbFSaVevbc6x+CVSxeg3H8U7XcbP/n9wWBXAQIY3vxniHlw==",
"requires": {
"async-validator": "^1.10.0",
"deepmerge": "^2.2.1",
"element-resize-detector": "^1.2.0",
"js-calendar": "^1.2.3",
"lodash.throttle": "^4.1.1",
"popper.js": "^1.14.6",
"tinycolor2": "^1.4.1",
"v-click-outside-x": "^3.5.6"
}
},
"js-calendar": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/js-calendar/-/js-calendar-1.2.3.tgz",
"integrity": "sha512-dAA1/Zbp4+c5E+ARCVTIuKepXsNLzSYfzvOimiYD4S5eeP9QuplSHLcdhfqFSwyM1o1u6ku6RRRCyaZ0YAjiBw=="
},
"js-levenshtein": { "js-levenshtein": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz",
...@@ -5384,6 +5426,11 @@ ...@@ -5384,6 +5426,11 @@
"integrity": "sha1-0jM6NtnncXyK0vfKyv7HwytERmQ=", "integrity": "sha1-0jM6NtnncXyK0vfKyv7HwytERmQ=",
"dev": true "dev": true
}, },
"lodash.throttle": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
"integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ="
},
"lodash.uniq": { "lodash.uniq": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
...@@ -6311,6 +6358,11 @@ ...@@ -6311,6 +6358,11 @@
"find-up": "^3.0.0" "find-up": "^3.0.0"
} }
}, },
"popper.js": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.15.0.tgz",
"integrity": "sha512-w010cY1oCUmI+9KwwlWki+r5jxKfTFDVoadl7MSrIujHU5MJ5OR6HTDj6Xo8aoR/QsA56x8jKjA59qGH4ELtrA=="
},
"portfinder": { "portfinder": {
"version": "1.0.20", "version": "1.0.20",
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.20.tgz", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.20.tgz",
...@@ -8299,6 +8351,11 @@ ...@@ -8299,6 +8351,11 @@
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=",
"dev": true "dev": true
}, },
"tinycolor2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.4.1.tgz",
"integrity": "sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g="
},
"to-arraybuffer": { "to-arraybuffer": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
...@@ -8666,6 +8723,11 @@ ...@@ -8666,6 +8723,11 @@
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
"dev": true "dev": true
}, },
"v-click-outside-x": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/v-click-outside-x/-/v-click-outside-x-3.7.1.tgz",
"integrity": "sha512-WmUgmcIXr9clVpm1AYS/FgHtcDicfnfoxgQCNg4O6vfk9GVnxA0vSqO321ogUo0b7czYTidj7fQENvWFMWOkUg=="
},
"v8-compile-cache": { "v8-compile-cache": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz",
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"vue-template-compiler": "^2.6.10" "vue-template-compiler": "^2.6.10"
}, },
"dependencies": { "dependencies": {
"iview": "^3.4.0",
"validate.js": "^0.12.0", "validate.js": "^0.12.0",
"vue-router": "^3.0.2", "vue-router": "^3.0.2",
"vuetify": "^1.5.7", "vuetify": "^1.5.7",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -16,14 +16,22 @@ if (token) { ...@@ -16,14 +16,22 @@ if (token) {
import Vue from 'vue'; import Vue from 'vue';
import Vuetify from 'vuetify'; import Vuetify from 'vuetify';
import iView from 'iview';
import App from './App.vue'; import App from './App.vue';
import router from './route'; import router from './route';
import store from './store'; import store from './store';
import 'iview/dist/styles/iview.css';
// Vue.config.productionTip = false; // Vue.config.productionTip = false;
Vue.use(Vuetify); Vue.use(Vuetify);
Vue.use(iView);
iView.LoadingBar.config({
height: 3
});
const app = new Vue({ const app = new Vue({
el: '#app', el: '#app',
......
import Vue from 'vue'; import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import iView from 'iview';
Vue.use(VueRouter); Vue.use(VueRouter);
...@@ -78,6 +79,7 @@ const router = new VueRouter({ ...@@ -78,6 +79,7 @@ const router = new VueRouter({
}) })
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
iView.LoadingBar.start();
if(to.matched.some(record => record.meta.requiredUser)) { if(to.matched.some(record => record.meta.requiredUser)) {
if(!localStorage.getItem('access_token')) { if(!localStorage.getItem('access_token')) {
next('/employer/login') next('/employer/login')
...@@ -89,4 +91,8 @@ router.beforeEach((to, from, next) => { ...@@ -89,4 +91,8 @@ router.beforeEach((to, from, next) => {
} }
}) })
router.afterEach(route => {
iView.LoadingBar.finish();
})
export default router export default router
\ No newline at end of file
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import iView from 'iview';
Vue.use(Vuex); Vue.use(Vuex);
...@@ -60,6 +61,7 @@ export default new Vuex.Store({ ...@@ -60,6 +61,7 @@ export default new Vuex.Store({
.then(res => { .then(res => {
commit('setLoading', false) commit('setLoading', false)
if (payload.role == 1) { if (payload.role == 1) {
iView.LoadingBar.finish()
localStorage.setItem('access_token', res.data.token) localStorage.setItem('access_token', res.data.token)
commit('setJwt', res.data.token) commit('setJwt', res.data.token)
dispatch('checkUser') dispatch('checkUser')
...@@ -78,9 +80,14 @@ export default new Vuex.Store({ ...@@ -78,9 +80,14 @@ export default new Vuex.Store({
console.log(res) console.log(res)
}) })
.catch(err => { .catch(err => {
iView.LoadingBar.error()
commit('setLoading', false) commit('setLoading', false)
if (err.response.data.error === 'invalid_credentials') { if (err.response.data.error === 'invalid_credentials') {
commit('setError', 'ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง') if (payload.role === 1) {
commit('setError', 'อีเมลหรือรหัสผ่านไม่ถูกต้อง')
} else {
commit('setError', 'ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง')
}
setTimeout(() => { setTimeout(() => {
commit('setError', null) commit('setError', null)
}, 4000); }, 4000);
...@@ -95,6 +102,9 @@ export default new Vuex.Store({ ...@@ -95,6 +102,9 @@ export default new Vuex.Store({
commit('setLoading', true) commit('setLoading', true)
axios.post('api/auth/register', payload) axios.post('api/auth/register', payload)
.then(res => { .then(res => {
if (payload.role === 1) {
iView.LoadingBar.finish()
}
commit('setLoading', false) commit('setLoading', false)
commit('setSnackbar', { commit('setSnackbar', {
show: true, show: true,
...@@ -106,19 +116,34 @@ export default new Vuex.Store({ ...@@ -106,19 +116,34 @@ export default new Vuex.Store({
resolve(res) resolve(res)
}) })
.catch(err => { .catch(err => {
iView.LoadingBar.error()
commit('setLoading', false) commit('setLoading', false)
console.log(err.response) console.log(err.response)
if (err.response.data == '{"email":["The email has already been taken."]}') { const error = JSON.parse(err.response.data);
commit('setError', 'อีเมลล์นี้ถูกใช้งานเเล้ว') if (error.username && error.email) {
commit('setError', 'ชื่อผู้ใช้เเละอีเมลถูกใช้งานเเล้ว')
setTimeout(() => {
commit('setError', null)
}, 4000);
} else if (error.email) {
commit('setError', 'อีเมลนี้ถูกใช้งานเเล้ว')
setTimeout(() => {
commit('setError', null)
}, 4000);
errorMessage = 'อีเมลนี้ถูกใช้งานเเล้ว'
} else if (error.username) {
commit('setError', 'ชื่อผู้ใช้นี้ถูกใช้งานเเล้ว')
setTimeout(() => { setTimeout(() => {
commit('setError', null) commit('setError', null)
}, 4000); }, 4000);
errorMessage = 'ชื่อผู้ใช้นี้ถูกใช้งานเเล้ว'
} }
reject(err.response) reject(err.response)
}) })
}) })
}, },
logout ({commit}) { logout ({commit}) {
iView.LoadingBar.finish()
localStorage.removeItem('access_token') localStorage.removeItem('access_token')
commit('setUser', { commit('setUser', {
name: null, name: null,
......
...@@ -112,6 +112,8 @@ export default { ...@@ -112,6 +112,8 @@ export default {
.then(res => { .then(res => {
this.$refs.login.reset() this.$refs.login.reset()
}) })
} else {
this.$Loading.error()
} }
} }
} }
......
...@@ -28,6 +28,13 @@ ...@@ -28,6 +28,13 @@
required required
></v-text-field> ></v-text-field>
<a href="#" class="body-2 font-weight-medium my-3">ลืมรหัสผ่าน</a> <a href="#" class="body-2 font-weight-medium my-3">ลืมรหัสผ่าน</a>
<p class="text-xs-center"><v-alert
:value="!!error"
color="error"
outline
>
{{ error }}
</v-alert></p>
<v-btn color="cyan darken-4" large dark block type="submit">เข้าสู่ระบบ</v-btn> <v-btn color="cyan darken-4" large dark block type="submit">เข้าสู่ระบบ</v-btn>
</v-form> </v-form>
<v-layout row wrap justify-center class="my-2"> <v-layout row wrap justify-center class="my-2">
...@@ -76,15 +83,22 @@ export default { ...@@ -76,15 +83,22 @@ export default {
}, },
methods: { methods: {
login () { login () {
this.$store.dispatch('login', this.loginData) if (this.$refs.loginEmployer.validate()) {
.then(res => { this.$store.dispatch('login', this.loginData)
this.$router.push('/Employer') .then(res => {
}) this.$router.push('/Employer')
})
} else {
this.$Loading.error()
}
} }
}, },
computed: { computed: {
loading () { loading () {
return this.$store.getters.getLoading return this.$store.getters.getLoading
},
error () {
return this.$store.getters.getError
} }
} }
} }
......
...@@ -157,6 +157,8 @@ export default { ...@@ -157,6 +157,8 @@ export default {
.then(res => { .then(res => {
this.$refs.register.reset() this.$refs.register.reset()
}) })
} else {
this.$Loading.error()
} }
} }
} }
......
...@@ -79,11 +79,19 @@ ...@@ -79,11 +79,19 @@
class="mg-ip" class="mg-ip"
required required
></v-text-field> ></v-text-field>
</v-flex>
<v-flex class="px-3">
<p><v-alert
:value="!!error"
color="error"
outline
>
{{ error }}
</v-alert></p>
</v-flex> </v-flex>
</v-layout> </v-layout>
<v-layout row wrap justify-center> <v-layout row wrap justify-center>
<v-btn color="cyan darken-4 my-3" dark type="submit">สมัครสมาชิก</v-btn> <v-btn color="cyan darken-4 my-3" dark type="submit">สมัครสมาชิก</v-btn>
</v-layout> </v-layout>
<v-layout row wrap justify-center> <v-layout row wrap justify-center>
<span class="body-2 font-weight-medium">มีบัญชีผู้ใช้แล้ว? <router-link to="/employer/login">เข้าสู่ระบบ</router-link></span> <span class="body-2 font-weight-medium">มีบัญชีผู้ใช้แล้ว? <router-link to="/employer/login">เข้าสู่ระบบ</router-link></span>
...@@ -143,6 +151,9 @@ export default { ...@@ -143,6 +151,9 @@ export default {
}, },
loading () { loading () {
return this.$store.getters.getLoading return this.$store.getters.getLoading
},
error () {
return this.$store.getters.getError
} }
}, },
methods: { methods: {
...@@ -150,8 +161,10 @@ export default { ...@@ -150,8 +161,10 @@ export default {
if(this.$refs.registerEmployer.validate()) { if(this.$refs.registerEmployer.validate()) {
this.$store.dispatch('register', this.registerData) this.$store.dispatch('register', this.registerData)
.then(res => { .then(res => {
this.$router.push('/login') this.$router.push('/employer/login')
}) })
} else {
this.$Loading.error()
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment