diff --git a/src/api/subscriber.js b/src/api/subscriber.js index 597367d1..c90f7f1a 100644 --- a/src/api/subscriber.js +++ b/src/api/subscriber.js @@ -9,7 +9,9 @@ import { get, patchAdd, patchReplace, + patchReplaceFull, patchAddFull + } from './common' import { assignNumbers @@ -502,3 +504,17 @@ export function setSubscriberNumbers(options) { }); } +export function changePassword(subscriber, newPassword) { + return new Promise((resolve, reject)=>{ + patchReplaceFull({ + path: 'api/subscribers/' + subscriber, + fieldPath: 'webpassword', + value: newPassword + }).then((subscriber)=>{ + resolve(subscriber); + }).catch((err)=>{ + reject(err); + }); + }); +} + diff --git a/src/components/layouts/UserMenu.vue b/src/components/layouts/CscLanguageMenu.vue similarity index 97% rename from src/components/layouts/UserMenu.vue rename to src/components/layouts/CscLanguageMenu.vue index 447b1fa2..45fd8477 100644 --- a/src/components/layouts/UserMenu.vue +++ b/src/components/layouts/CscLanguageMenu.vue @@ -35,7 +35,7 @@ QSideLink } from 'quasar-framework' export default { - name: 'csc-user-menu', + name: 'csc-language-menu', props: [ 'languageLabel', 'languageLabels' diff --git a/src/components/layouts/CscUserMenu.vue b/src/components/layouts/CscUserMenu.vue new file mode 100644 index 00000000..76ede186 --- /dev/null +++ b/src/components/layouts/CscUserMenu.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/components/layouts/Default.vue b/src/components/layouts/Default.vue index c0b08879..a284ce86 100644 --- a/src/components/layouts/Default.vue +++ b/src/components/layouts/Default.vue @@ -30,8 +30,10 @@ round small > - - + {{ getUsername }} - - - - - - - - + + - + +
+
+ +
+
+
+ + + + + diff --git a/src/components/pages/UserSettings/CscChangePassword.vue b/src/components/pages/UserSettings/CscChangePassword.vue new file mode 100644 index 00000000..bbc88db5 --- /dev/null +++ b/src/components/pages/UserSettings/CscChangePassword.vue @@ -0,0 +1,158 @@ + + + + + diff --git a/src/locales/en.json b/src/locales/en.json index 06e252d4..8ce96250 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -593,5 +593,18 @@ "exitDialogTitle": "Leave conference", "exitDialogText": "Leave current conference now!", "leaveButtonLabel": "Leave" + }, + "userSettings": { + "changePassword": "Change password", + "saveNewPassword": "Save new password", + "newPasswordLabel": "New password", + "newPasswordRetypedLabel": "New password retyped", + "changePasswordDialogTitle": "Change login password", + "changePasswordDialogText": "You are about to change your login password. After the password was changed successfully, you get automatically logged out to authenticate with the new password. ", + "changePasswordToast": "Your password has been changed successfully" + }, + "userMenu": { + "logout": "Logout", + "settings": "Settings" } } diff --git a/src/routes.js b/src/routes.js index be5305f2..9549bbc3 100644 --- a/src/routes.js +++ b/src/routes.js @@ -22,6 +22,7 @@ import PbxConfigurationSoundSets from './components/pages/PbxConfiguration/CscPb import PbxConfigurationMsConfigs from './components/pages/PbxConfiguration/CscPbxMsConfigs' import Voicebox from './components/pages/Voicebox/Voicebox'; import Login from './components/Login' +import CscUserSettings from './components/pages/CscUserSettings' import Error404 from './components/Error404' export default [ @@ -163,6 +164,14 @@ export default [ title: i18n.t('navigation.voicebox.title'), subtitle: i18n.t('navigation.voicebox.subTitle') } + }, + { + path: 'settings', + component: CscUserSettings, + meta: { + title: i18n.t('navigation.userSettings.title'), + subtitle: i18n.t('navigation.userSettings.subTitle') + } } ] }, diff --git a/src/store/user.js b/src/store/user.js index bd316f3a..57696549 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -15,6 +15,7 @@ import { login, getUserData } from '../api/user'; +import {changePassword} from "../api/subscriber"; export default { namespaced: true, @@ -38,7 +39,9 @@ export default { sessionLocale: null, changeSessionLocaleState: RequestState.initiated, changeSessionLocaleError: null, - languageLabels: [] + languageLabels: [], + changePasswordState: RequestState.initiated, + changePasswordError: null }, getters: { isLogged(state) { @@ -136,6 +139,12 @@ export default { }, languageLabels(state) { return state.languageLabels; + }, + getSubscriber(state) { + return state.subscriber; + }, + isPasswordChanging(state) { + return state.changePasswordState === RequestState.requesting; } }, mutations: { @@ -210,6 +219,18 @@ export default { }, setLanguageLabels(state, languageLabels) { state.languageLabels = languageLabels; + }, + userPasswordRequesting(state) { + state.changePasswordState = RequestState.requesting; + state.changePasswordError = null; + }, + userPasswordSucceeded(state) { + state.changePasswordState = RequestState.succeeded; + state.changePasswordError = null; + }, + userPasswordFailed(state, error) { + state.changePasswordState = RequestState.failed; + state.changePasswordError = error; } }, actions: { @@ -275,6 +296,16 @@ export default { catch(error) { context.commit('changeSessionLocaleFailed', error); } + }, + changePassword(context, newPassword) { + let subscriberId = localStorage.getItem('subscriberId'); + context.commit('userPasswordRequesting'); + changePassword(subscriberId, newPassword).then(()=>{ + context.commit('userPasswordSucceeded'); + context.dispatch('logout'); + }).catch((err)=>{ + context.commit('userPasswordFailed', err.message); + }); } } };