diff --git a/src/components/users/Authorization.vue b/src/components/users/Authorization.vue new file mode 100644 index 00000000..e69de29b diff --git a/src/components/users/Confirmation.vue b/src/components/users/Confirmation.vue new file mode 100644 index 00000000..b4a4cd73 --- /dev/null +++ b/src/components/users/Confirmation.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/main.js b/src/main.js index 9912c5d2..e699c76c 100644 --- a/src/main.js +++ b/src/main.js @@ -23,7 +23,7 @@ Vue.use(BootstrapVue) const apiSettings = new ApiSettings() // Set axios authorization headers. -const apiToken = store.getters.apiAuthorizationToken +const apiToken = store.getters.user.token const apiType = apiSettings.authorizationType if (apiToken) axios.defaults.headers.common['Authorization'] = `${apiType} ${apiToken}` diff --git a/src/router/index.js b/src/router/index.js index 02062086..bd188c19 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,6 +5,8 @@ import Analytics from '@/components/Analytics' import Event from '@/components/Event' import Events from '@/components/Events' import StaticPage from '@/components/StaticPage' +import UserAuthorization from '@/components/users/Authorization' +import UserEmailConfirmation from '@/components/users/Confirmation' import UserRegistration from '@/components/users/Registration' Vue.use(Router) @@ -21,6 +23,16 @@ export default new Router({ name: 'UserRegistration', component: UserRegistration }, + { + path: '/register/confirm/:token', + name: 'UserEmailConfirmation', + component: UserEmailConfirmation + }, + { + path: '/sign_in', + name: 'UserAuthorization', + component: UserAuthorization + }, { path: '/analytics', name: 'Analytics', diff --git a/src/settings/api.js b/src/settings/api.js index 0896f2e6..890113da 100644 --- a/src/settings/api.js +++ b/src/settings/api.js @@ -15,6 +15,10 @@ class Config { this.endpointUserRegistration = `${this.baseURL}/${this.version}/user/register` } + endpointEmailConfirmation(token) { + return `${this.baseURL}/${this.version}/user/emailConfirm/${token}` + } + endpointEventBuildings(id) { return `${this.baseURL}/${this.version}/msk64/damagedBuildings/${id}` } diff --git a/src/store/app.js b/src/store/app.js new file mode 100644 index 00000000..5d73423e --- /dev/null +++ b/src/store/app.js @@ -0,0 +1,100 @@ +export default { + state: { + api: { + authorizationToken: '' + }, + counters: { + totalEvents: 0 + }, + currentTileProvider: '', + msk64Config: { + configVersion: '' + }, + pgaConfig: { + configVersion: '' + }, + plateBoundaries: [], + srssCoreConfig: { + dbVersion: '' + } + }, + getters: { + apiAuthorizationToken: state => { return state.api.authorizationToken }, + currentTileProvider: state => { return state.currentTileProvider }, + chartDataset: () => { + return { + datasets: [{ + label: '', + data: [], + fill: true, + lineTension: 0.1, + backgroundColor: 'rgba(51,122,183,0.4)', + borderColor: 'rgba(51,122,183,1)', + borderCapStyle: 'butt', + borderDash: [], + borderDashOffset: 0.0, + borderJoinStyle: 'miter', + pointBorderColor: 'rgba(51,122,183,1)', + pointBackgroundColor: 'rgba(51,122,183,1)', + pointBorderWidth: 1, + pointHoverRadius: 5, + pointHoverBackgroundColor: 'rgba(51,122,183,1)', + pointHoverBorderColor: 'rgba(51,122,183,1)', + pointHoverBorderWidth: 2, + pointRadius: 1, + pointHitRadius: 10 + }], + labels: [] + } + }, + msk64ConfigVersion: state => { return state.msk64Config.configVersion }, + pgaConfigVersion: state => { return state.pgaConfig.configVersion }, + plateBoundaries: state => { return state.plateBoundaries }, + srssDBVersion: state => { return state.srssCoreConfig.dbVersion }, + totalEventsCount: state => { return state.counters.totalEvents } + }, + mutations: { + setCurrentTileProvider(state, { key, value }) { + state[key] = value + }, + setPlateBoundaries(state, { key, value }) { + state[key] = value + }, + setCounter(state, { key, value }) { + state.counters[key] = value + }, + setMsk64Config(state, { key, value }) { + state.msk64Config[key] = value + }, + setPgaConfig(state, { key, value }) { + state.pgaConfig[key] = value + }, + setSrssDBVersion(state, { key, value }) { + state.srssCoreConfig[key] = value + } + }, + actions: { + setCurrentTileProvider({ commit, state }, provider) { + if (provider !== state.currentTileProvider) { + commit('setCurrentTileProvider', { key: 'currentTileProvider', value: provider }) + } + }, + setPlateBoundaries({ commit, state }, value) { + if (value !== state.plateBoundaries) { + commit('setPlateBoundaries', { key: 'plateBoundaries', value: value }) + } + }, + setTotalEventsCount({ commit }, value) { + commit('setCounter', { key: 'totalEvents', value: value }) + }, + setMsk64ConfigVersion({ commit }, value) { + commit('setMsk64Config', { key: 'configVersion', value: value }) + }, + setPgaConfigVersion({ commit }, value) { + commit('setPgaConfig', { key: 'configVersion', value: value }) + }, + setSrssDBVersion({ commit }, value) { + commit('setSrssDBVersion', { key: 'dbVersion', value: value }) + } + } +} diff --git a/src/store/index.js b/src/store/index.js index 1aded2ef..91c07a25 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,111 +1,24 @@ import Vue from 'vue' import Vuex from 'vuex' + +import app from './app' +import user from './user' + import createPersistedState from 'vuex-persistedstate' Vue.use(Vuex) export default new Vuex.Store({ - state: { - api: { - authorizationToken: '' - }, - counters: { - totalEvents: 0 - }, - currentTileProvider: '', - msk64Config: { - configVersion: '' - }, - pgaConfig: { - configVersion: '' - }, - plateBoundaries: [], - srssCoreConfig: { - dbVersion: '' - } - }, - getters: { - apiAuthorizationToken: state => { return state.api.authorizationToken }, - currentTileProvider: state => { return state.currentTileProvider }, - chartDataset: () => { - return { - datasets: [{ - label: '', - data: [], - fill: true, - lineTension: 0.1, - backgroundColor: 'rgba(51,122,183,0.4)', - borderColor: 'rgba(51,122,183,1)', - borderCapStyle: 'butt', - borderDash: [], - borderDashOffset: 0.0, - borderJoinStyle: 'miter', - pointBorderColor: 'rgba(51,122,183,1)', - pointBackgroundColor: 'rgba(51,122,183,1)', - pointBorderWidth: 1, - pointHoverRadius: 5, - pointHoverBackgroundColor: 'rgba(51,122,183,1)', - pointHoverBorderColor: 'rgba(51,122,183,1)', - pointHoverBorderWidth: 2, - pointRadius: 1, - pointHitRadius: 10 - }], - labels: [] - } - }, - msk64ConfigVersion: state => { return state.msk64Config.configVersion }, - pgaConfigVersion: state => { return state.pgaConfig.configVersion }, - plateBoundaries: state => { return state.plateBoundaries }, - srssDBVersion: state => { return state.srssCoreConfig.dbVersion }, - totalEventsCount: state => { return state.counters.totalEvents } - }, - mutations: { - set(state, { key, value }) { - state[key] = value - }, - setCounter(state, { key, value }) { - state.counters[key] = value - }, - setMsk64Config(state, { key, value }) { - state.msk64Config[key] = value - }, - setPgaConfig(state, { key, value }) { - state.pgaConfig[key] = value - }, - setSrssDBVersion(state, { key, value }) { - state.srssCoreConfig[key] = value - } - }, - actions: { - setCurrentTileProvider({ commit, state }, provider) { - if (provider !== state.currentTileProvider) { - commit('set', { key: 'currentTileProvider', value: provider }) - } - }, - setPlateBoundaries({ commit, state }, value) { - if (value !== state.plateBoundaries) { - commit('set', { key: 'plateBoundaries', value: value }) - } - }, - setTotalEventsCount({ commit }, value) { - commit('setCounter', { key: 'totalEvents', value: value }) - }, - setMsk64ConfigVersion({ commit }, value) { - commit('setMsk64Config', { key: 'configVersion', value: value }) - }, - setPgaConfigVersion({ commit }, value) { - commit('setPgaConfig', { key: 'configVersion', value: value }) - }, - setSrssDBVersion({ commit }, value) { - commit('setSrssDBVersion', { key: 'dbVersion', value: value }) - } + modules: { + app: app, + user: user }, plugins: [createPersistedState({ filter: (mutation) => { - // Store in localStorage only currentTileProvider or plateBoundaries. - switch (mutation.payload.key) { - case 'currentTileProvider': - case 'plateBoundaries': return true + switch (mutation.type) { + case 'setCurrentTileProvider': + case 'setPlateBoundaries': + case 'setUser': return true default: return false } } diff --git a/src/store/user.js b/src/store/user.js new file mode 100644 index 00000000..e2a2e17b --- /dev/null +++ b/src/store/user.js @@ -0,0 +1,31 @@ +export default { + state: { + authorized: false, + token: null, + refreshToken: null + }, + getters: { + user: state => { + return { + authorized: state.authorized, + token: state.token, + refreshToken: state.refreshToken + } + } + }, + mutations: { + setUser(state, { key, value }) { + state[key] = value + } + }, + actions: { + setUserAuthorized({ commit, state }, value) { + commit('setUser', { key: 'authorized', value: value }) + }, + setUserTokens({ commit, state }, value) { + commit('setUser', { key: 'token', value: value.token }) + commit('setUser', { key: 'refreshToken', value: value.refreshToken }) + commit('setUser', { key: 'authorized', value: true }) + } + } +}