-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Password change self service on account info page
- Loading branch information
Jan
committed
Jul 4, 2022
1 parent
1275654
commit db0e69f
Showing
6 changed files
with
267 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Add change own password dialog to the account info page | ||
|
||
We have added a new change own password dialog to the account info page, | ||
so the user has the possibility to change their own password. | ||
|
||
https://github.com/owncloud/web/pull/7206 | ||
https://github.com/owncloud/web/issues/7183 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<template> | ||
<oc-modal | ||
:title="$gettext('Change password')" | ||
:button-cancel-text="$gettext('Cancel')" | ||
:button-confirm-text="$gettext('Confirm')" | ||
:button-confirm-disabled="confirmButtonDisabled" | ||
@confirm="editPassword" | ||
@cancel="$emit('cancel')" | ||
> | ||
<template #content> | ||
<oc-text-input | ||
v-model="currentPassword" | ||
:label="$gettext('Current password')" | ||
type="password" | ||
:fix-message-line="true" | ||
/> | ||
<oc-text-input | ||
v-model="newPassword" | ||
:label="$gettext('New password')" | ||
type="password" | ||
:fix-message-line="true" | ||
@change="validatePasswordConfirm" | ||
/> | ||
<oc-text-input | ||
v-model="newPasswordConfirm" | ||
:label="$gettext('Repeat new password')" | ||
type="password" | ||
:fix-message-line="true" | ||
:error-message="passwordConfirmErrorMessage" | ||
@change="validatePasswordConfirm" | ||
/> | ||
</template> | ||
</oc-modal> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'EditPasswordModal', | ||
data: function () { | ||
return { | ||
currentPassword: '', | ||
newPassword: '', | ||
newPasswordConfirm: '', | ||
passwordConfirmErrorMessage: '' | ||
} | ||
}, | ||
computed: { | ||
confirmButtonDisabled() { | ||
return ( | ||
!this.currentPassword.trim().length || | ||
!this.newPassword.trim().length || | ||
this.newPassword !== this.newPasswordConfirm | ||
) | ||
} | ||
}, | ||
methods: { | ||
editPassword() { | ||
this.$emit('confirm', this.currentPassword, this.newPassword) | ||
}, | ||
validatePasswordConfirm() { | ||
this.passwordConfirmErrorMessage = '' | ||
if ( | ||
this.newPassword.trim().length && | ||
this.newPasswordConfirm.trim().length && | ||
this.newPassword !== this.newPasswordConfirm | ||
) { | ||
this.passwordConfirmErrorMessage = this.$gettext( | ||
'Password and password confirmation must be identical' | ||
) | ||
return false | ||
} | ||
return true | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/web-runtime/tests/unit/components/EditPasswordModal.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Vuex from 'vuex' | ||
import { mount, createLocalVue } from '@vue/test-utils' | ||
import EditPasswordModal from '../../../src/components/EditPasswordModal' | ||
|
||
const localVue = createLocalVue() | ||
localVue.use(Vuex) | ||
|
||
afterEach(() => jest.clearAllMocks()) | ||
|
||
describe('EditPasswordModal', () => { | ||
describe('computed method "confirmButtonDisabled"', () => { | ||
it('should be true if any data set is invalid', () => { | ||
const wrapper = getWrapper() | ||
wrapper.vm.currentPassword = '' | ||
expect(wrapper.vm.confirmButtonDisabled).toBeTruthy() | ||
}) | ||
it('should be false if no data set is invalid', () => { | ||
const wrapper = getWrapper() | ||
wrapper.vm.currentPassword = 'password' | ||
wrapper.vm.newPassword = 'newpassword' | ||
wrapper.vm.newPasswordConfirm = 'newpassword' | ||
expect(wrapper.vm.confirmButtonDisabled).toBeFalsy() | ||
}) | ||
}) | ||
|
||
describe('method "validatePasswordConfirm"', () => { | ||
it('should be true if passwords are identical', () => { | ||
const wrapper = getWrapper() | ||
wrapper.vm.newPassword = 'newpassword' | ||
wrapper.vm.newPasswordConfirm = 'newpassword' | ||
expect(wrapper.vm.validatePasswordConfirm).toBeTruthy() | ||
}) | ||
it('should be false if passwords are not identical', () => { | ||
const wrapper = getWrapper() | ||
wrapper.vm.newPassword = 'newpassword' | ||
wrapper.vm.newPasswordConfirm = 'anothernewpassword' | ||
expect(wrapper.vm.validatePasswordConfirm).toBeTruthy() | ||
}) | ||
}) | ||
}) | ||
|
||
function getWrapper() { | ||
return mount(EditPasswordModal, { | ||
localVue, | ||
mocks: { | ||
$gettext: jest.fn(), | ||
$gettextInterpolate: jest.fn() | ||
}, | ||
propsData: { | ||
cancel: jest.fn(), | ||
confirm: jest.fn(), | ||
existingGroups: [ | ||
{ | ||
displayName: 'admins' | ||
} | ||
] | ||
}, | ||
stubs: { 'oc-modal': true, 'oc-text-input': true } | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters