Signed-off-by: Carl Schwan <carl@carlschwan.eu>tags/v25.0.0beta4
use OCP\IUserSession; | use OCP\IUserSession; | ||||
class ChangePasswordController extends Controller { | class ChangePasswordController extends Controller { | ||||
/** @var string */ | |||||
private $userId; | |||||
/** @var IUserManager */ | |||||
private $userManager; | |||||
/** @var IL10N */ | |||||
private $l; | |||||
/** @var GroupManager */ | |||||
private $groupManager; | |||||
/** @var Session */ | |||||
private $userSession; | |||||
/** @var IAppManager */ | |||||
private $appManager; | |||||
private ?string $userId; | |||||
private IUserManager $userManager; | |||||
private IL10N $l; | |||||
private GroupManager $groupManager; | |||||
private Session $userSession; | |||||
private IAppManager $appManager; | |||||
public function __construct(string $appName, | public function __construct(string $appName, | ||||
IRequest $request, | IRequest $request, | ||||
string $userId, | |||||
?string $userId, | |||||
IUserManager $userManager, | IUserManager $userManager, | ||||
IUserSession $userSession, | IUserSession $userSession, | ||||
IGroupManager $groupManager, | IGroupManager $groupManager, |
<!-- | |||||
- @copyright 2022 Carl Schwan <carl@carlschwan.eu> | |||||
- | |||||
- @license GNU AGPL version 3 or any later version | |||||
- | |||||
- This program is free software: you can redistribute it and/or modify | |||||
- it under the terms of the GNU Affero General Public License as | |||||
- published by the Free Software Foundation, either version 3 of the | |||||
- License, or (at your option) any later version. | |||||
- | |||||
- This program is distributed in the hope that it will be useful, | |||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
- GNU Affero General Public License for more details. | |||||
- | |||||
- You should have received a copy of the GNU Affero General Public License | |||||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
--> | |||||
<template> | |||||
<NcSettingsSection :title="t('settings', 'Password')"> | |||||
<form id="passwordform" method="POST" @submit.prevent="changePassword"> | |||||
<NcPasswordField id="old-pass" | |||||
:label="t('settings', 'Current password')" | |||||
:label-visible="true" | |||||
name="oldpassword" | |||||
:value.sync="oldPass" | |||||
autocomplete="current-password" | |||||
autocapitalize="none" | |||||
autocorrect="off" /> | |||||
<NcPasswordField id="new-pass" | |||||
:label="t('settings', 'New password')" | |||||
:label-visible="true" | |||||
:value.sync="newPass" | |||||
:maxlength="469" | |||||
autocomplete="new-password" | |||||
autocapitalize="none" | |||||
autocorrect="off" | |||||
:check-password-strength="true" /> | |||||
<NcButton type="primary" | |||||
native-type="submit" | |||||
:disabled="newPass.length === 0 || oldPass.length === 0"> | |||||
{{ t('settings', 'Change password') }} | |||||
</NcButton> | |||||
</form> | |||||
</NcSettingsSection> | |||||
</template> | |||||
<script> | |||||
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js' | |||||
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' | |||||
import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js' | |||||
import axios from '@nextcloud/axios' | |||||
import { generateUrl } from '@nextcloud/router' | |||||
import { showSuccess, showError } from '@nextcloud/dialogs' | |||||
export default { | |||||
name: 'PasswordSection', | |||||
components: { | |||||
NcSettingsSection, | |||||
NcButton, | |||||
NcPasswordField, | |||||
}, | |||||
data() { | |||||
return { | |||||
oldPass: '', | |||||
newPass: '', | |||||
} | |||||
}, | |||||
methods: { | |||||
changePassword() { | |||||
axios.post(generateUrl('/settings/personal/changepassword'), { | |||||
oldpassword: this.oldPass, | |||||
newpassword: this.newPass, | |||||
}) | |||||
.then(res => res.data) | |||||
.then(data => { | |||||
if (data.status === 'error') { | |||||
this.errorMessage = data.data.message | |||||
showError(data.data.message) | |||||
} else { | |||||
showSuccess(data.data.message) | |||||
} | |||||
}) | |||||
}, | |||||
}, | |||||
} | |||||
</script> | |||||
<style> | |||||
#passwordform { | |||||
display: flex; | |||||
flex-direction: column; | |||||
gap: 1rem; | |||||
max-width: 400px; | |||||
} | |||||
</style> |
/** | |||||
* @copyright 2022 Carl Schwan <carl@carlschwan.eu> | |||||
* | |||||
* @license AGPL-3.0-or-later | |||||
* | |||||
* This program is free software: you can redistribute it and/or modify | |||||
* it under the terms of the GNU Affero General Public License as | |||||
* published by the Free Software Foundation, either version 3 of the | |||||
* License, or (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU Affero General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU Affero General Public License | |||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
* | |||||
*/ | |||||
import Vue from 'vue' | |||||
import PasswordSection from './components/PasswordSection.vue' | |||||
import { translate as t, translatePlural as n } from '@nextcloud/l10n' | |||||
// eslint-disable-next-line camelcase | |||||
__webpack_nonce__ = btoa(OC.requestToken) | |||||
Vue.prototype.t = t | |||||
Vue.prototype.n = n | |||||
export default new Vue({ | |||||
el: '#security-password', | |||||
name: 'main-personal-password', | |||||
render: h => h(PasswordSection), | |||||
}) |
<?php | <?php | ||||
/** | /** | ||||
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> | * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> | ||||
* @copyright Copyright (c) 2022 Carl Schwan <carl@carlschwan.eu> | |||||
* | * | ||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de> | * @author Arthur Schiwon <blizzz@arthur-schiwon.de> | ||||
* | * | ||||
* | * | ||||
*/ | */ | ||||
script('settings', [ | |||||
'settings', | |||||
'templates', | |||||
'vue-settings-personal-security', | |||||
]); | |||||
if ($_['passwordChangeSupported']) { | if ($_['passwordChangeSupported']) { | ||||
script('settings', 'security_password'); | |||||
\OCP\Util::addScript('settings', 'vue-settings-personal-password'); | |||||
} | } | ||||
?> | ?> | ||||
<?php if ($_['passwordChangeSupported']) { ?> | |||||
<div id="security-password" class="section"> | |||||
<h2 class="inlineblock"><?php p($l->t('Password'));?></h2> | |||||
<span id="password-error-msg" class="msg success hidden">Saved</span> | |||||
<div class="personal-settings-setting-box personal-settings-password-box"> | |||||
<form id="passwordform" method="POST"> | |||||
<div class="input-control"> | |||||
<label for="pass1"><?php p($l->t('Current password')); ?>: </label> | |||||
<input type="password" id="pass1" name="oldpassword" | |||||
placeholder="<?php p($l->t('Your current password'));?>" | |||||
autocomplete="current-password" autocapitalize="none" autocorrect="off" /> | |||||
</div> | |||||
<div class="personal-show-container"> | |||||
<label for="pass2" ><?php p($l->t('New password'));?>: </label> | |||||
<input type="password" id="pass2" name="newpassword" | |||||
maxlength="469" | |||||
placeholder="<?php p($l->t('Your new password')); ?>" | |||||
data-typetoggle="#personal-show" | |||||
autocomplete="new-password" autocapitalize="none" autocorrect="off" /> | |||||
<input type="checkbox" id="personal-show" class="hidden-visually" name="show" /> | |||||
<label for="personal-show" class="personal-show-label"></label> | |||||
</div> | |||||
<div> | |||||
<input id="passwordbutton" class="primary" type="submit" value="<?php p($l->t('Change password')); ?>" /> | |||||
</div> | |||||
</form> | |||||
</div> | |||||
<span class="msg"></span> | |||||
</div> | |||||
<?php } ?> | |||||
<div id="security-password"></div> |
/*! For license information please see NcMultiselect.js.LICENSE.txt */ | /*! For license information please see NcMultiselect.js.LICENSE.txt */ | ||||
/*! For license information please see NcPasswordField.js.LICENSE.txt */ | |||||
/*! For license information please see NcRichContenteditable.js.LICENSE.txt */ | /*! For license information please see NcRichContenteditable.js.LICENSE.txt */ | ||||
/*! For license information please see NcTimezonePicker.js.LICENSE.txt */ | /*! For license information please see NcTimezonePicker.js.LICENSE.txt */ |
/** | |||||
* @copyright 2022 Carl Schwan <carl@carlschwan.eu> | |||||
* | |||||
* @license AGPL-3.0-or-later | |||||
* | |||||
* This program is free software: you can redistribute it and/or modify | |||||
* it under the terms of the GNU Affero General Public License as | |||||
* published by the Free Software Foundation, either version 3 of the | |||||
* License, or (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU Affero General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU Affero General Public License | |||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
* | |||||
*/ |
"@nextcloud/paths": "^2.1.0", | "@nextcloud/paths": "^2.1.0", | ||||
"@nextcloud/router": "^2.0.0", | "@nextcloud/router": "^2.0.0", | ||||
"@nextcloud/sharing": "^0.1.0", | "@nextcloud/sharing": "^0.1.0", | ||||
"@nextcloud/vue": "^6.0.0-beta.4", | |||||
"@nextcloud/vue": "^6.0.0-beta.5", | |||||
"@nextcloud/vue-dashboard": "^2.0.1", | "@nextcloud/vue-dashboard": "^2.0.1", | ||||
"@vue/cli-plugin-unit-jest": "^4.5.15", | "@vue/cli-plugin-unit-jest": "^4.5.15", | ||||
"autosize": "^5.0.1", | "autosize": "^5.0.1", | ||||
} | } | ||||
}, | }, | ||||
"node_modules/@nextcloud/vue": { | "node_modules/@nextcloud/vue": { | ||||
"version": "6.0.0-beta.4", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-6.0.0-beta.4.tgz", | |||||
"integrity": "sha512-1TdzH0++/gIcBzot8iNT3AnweR/1EykpCfBwkJNhMgoiY4HlMLxBj7bpe2D4ul24XTCoXVEdGMYyB32GNVc9WA==", | |||||
"version": "6.0.0-beta.5", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-6.0.0-beta.5.tgz", | |||||
"integrity": "sha512-23vdV3Z9iyUXs5mGi++uGShpL1+lhNPLfjbnCjf9rIytG6XQV/46vzdBSttbBA91CnuEYufEsTu3grjwW9JiRg==", | |||||
"dependencies": { | "dependencies": { | ||||
"@nextcloud/auth": "^2.0.0", | "@nextcloud/auth": "^2.0.0", | ||||
"@nextcloud/axios": "^2.0.0", | "@nextcloud/axios": "^2.0.0", | ||||
"@nextcloud/capabilities": "^1.0.4", | "@nextcloud/capabilities": "^1.0.4", | ||||
"@nextcloud/dialogs": "^3.1.4", | "@nextcloud/dialogs": "^3.1.4", | ||||
"@nextcloud/event-bus": "^3.0.0", | "@nextcloud/event-bus": "^3.0.0", | ||||
"@nextcloud/initial-state": "^1.2.1", | |||||
"@nextcloud/l10n": "^1.6.0", | "@nextcloud/l10n": "^1.6.0", | ||||
"@nextcloud/logger": "^2.2.1", | "@nextcloud/logger": "^2.2.1", | ||||
"@nextcloud/router": "^2.0.0", | "@nextcloud/router": "^2.0.0", | ||||
} | } | ||||
}, | }, | ||||
"@nextcloud/vue": { | "@nextcloud/vue": { | ||||
"version": "6.0.0-beta.4", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-6.0.0-beta.4.tgz", | |||||
"integrity": "sha512-1TdzH0++/gIcBzot8iNT3AnweR/1EykpCfBwkJNhMgoiY4HlMLxBj7bpe2D4ul24XTCoXVEdGMYyB32GNVc9WA==", | |||||
"version": "6.0.0-beta.5", | |||||
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-6.0.0-beta.5.tgz", | |||||
"integrity": "sha512-23vdV3Z9iyUXs5mGi++uGShpL1+lhNPLfjbnCjf9rIytG6XQV/46vzdBSttbBA91CnuEYufEsTu3grjwW9JiRg==", | |||||
"requires": { | "requires": { | ||||
"@nextcloud/auth": "^2.0.0", | "@nextcloud/auth": "^2.0.0", | ||||
"@nextcloud/axios": "^2.0.0", | "@nextcloud/axios": "^2.0.0", | ||||
"@nextcloud/capabilities": "^1.0.4", | "@nextcloud/capabilities": "^1.0.4", | ||||
"@nextcloud/dialogs": "^3.1.4", | "@nextcloud/dialogs": "^3.1.4", | ||||
"@nextcloud/event-bus": "^3.0.0", | "@nextcloud/event-bus": "^3.0.0", | ||||
"@nextcloud/initial-state": "^1.2.1", | |||||
"@nextcloud/l10n": "^1.6.0", | "@nextcloud/l10n": "^1.6.0", | ||||
"@nextcloud/logger": "^2.2.1", | "@nextcloud/logger": "^2.2.1", | ||||
"@nextcloud/router": "^2.0.0", | "@nextcloud/router": "^2.0.0", |
"@nextcloud/paths": "^2.1.0", | "@nextcloud/paths": "^2.1.0", | ||||
"@nextcloud/router": "^2.0.0", | "@nextcloud/router": "^2.0.0", | ||||
"@nextcloud/sharing": "^0.1.0", | "@nextcloud/sharing": "^0.1.0", | ||||
"@nextcloud/vue": "^6.0.0-beta.4", | |||||
"@nextcloud/vue": "^6.0.0-beta.5", | |||||
"@nextcloud/vue-dashboard": "^2.0.1", | "@nextcloud/vue-dashboard": "^2.0.1", | ||||
"@vue/cli-plugin-unit-jest": "^4.5.15", | "@vue/cli-plugin-unit-jest": "^4.5.15", | ||||
"autosize": "^5.0.1", | "autosize": "^5.0.1", |
'vue-settings-personal-info': path.join(__dirname, 'apps/settings/src', 'main-personal-info.js'), | 'vue-settings-personal-info': path.join(__dirname, 'apps/settings/src', 'main-personal-info.js'), | ||||
'vue-settings-personal-security': path.join(__dirname, 'apps/settings/src', 'main-personal-security.js'), | 'vue-settings-personal-security': path.join(__dirname, 'apps/settings/src', 'main-personal-security.js'), | ||||
'vue-settings-personal-webauthn': path.join(__dirname, 'apps/settings/src', 'main-personal-webauth.js'), | 'vue-settings-personal-webauthn': path.join(__dirname, 'apps/settings/src', 'main-personal-webauth.js'), | ||||
'vue-settings-personal-password': path.join(__dirname, 'apps/settings/src', 'main-personal-password.js'), | |||||
'legacy-admin': path.join(__dirname, 'apps/settings/src', 'admin.js'), | 'legacy-admin': path.join(__dirname, 'apps/settings/src', 'admin.js'), | ||||
'apps': path.join(__dirname, 'apps/settings/src', 'apps.js'), | 'apps': path.join(__dirname, 'apps/settings/src', 'apps.js'), | ||||
}, | }, |