feat(recover-password): use user
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
refs #5170
This commit is contained in:
parent
96a3ae8912
commit
4a587049fc
|
@ -3,9 +3,9 @@ module.exports = Self => {
|
|||
description: 'Send email to the user',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'email',
|
||||
arg: 'user',
|
||||
type: 'string',
|
||||
description: 'The email of user',
|
||||
description: 'The user name or email',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
|
@ -15,11 +15,20 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.recoverPassword = async function(email) {
|
||||
Self.recoverPassword = async function(user) {
|
||||
const models = Self.app.models;
|
||||
|
||||
const usesEmail = user.indexOf('@') !== -1;
|
||||
if (!usesEmail) {
|
||||
const account = await models.Account.findOne({
|
||||
fields: ['email'],
|
||||
where: {name: user}
|
||||
});
|
||||
user = account.email;
|
||||
}
|
||||
|
||||
try {
|
||||
await models.user.resetPassword({email, emailTemplate: 'recover-password'});
|
||||
await models.user.resetPassword({email: user, emailTemplate: 'recover-password'});
|
||||
} catch (err) {
|
||||
if (err.code === 'EMAIL_NOT_FOUND')
|
||||
return;
|
||||
|
|
|
@ -31,7 +31,7 @@ export default {
|
|||
},
|
||||
recoverPassword: {
|
||||
recoverPasswordButton: 'vn-login a[ui-sref="recover-password"]',
|
||||
email: 'vn-recover-password vn-textfield[ng-model="$ctrl.email"]',
|
||||
email: 'vn-recover-password vn-textfield[ng-model="$ctrl.user"]',
|
||||
sendEmailButton: 'vn-recover-password vn-submit',
|
||||
},
|
||||
accountIndex: {
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('RecoverPassword path', async() => {
|
|||
expect(message.text).toContain('Notification sent!');
|
||||
});
|
||||
|
||||
it('should send email', async() => {
|
||||
it('should send email using email', async() => {
|
||||
await page.waitForState('login');
|
||||
await page.waitToClick(selectors.recoverPassword.recoverPasswordButton);
|
||||
|
||||
|
@ -37,4 +37,16 @@ describe('RecoverPassword path', async() => {
|
|||
|
||||
expect(message.text).toContain('Notification sent!');
|
||||
});
|
||||
|
||||
it('should send email using username', async() => {
|
||||
await page.waitForState('login');
|
||||
await page.waitToClick(selectors.recoverPassword.recoverPasswordButton);
|
||||
|
||||
await page.write(selectors.recoverPassword.email, 'BruceWayne');
|
||||
await page.waitToClick(selectors.recoverPassword.sendEmailButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
await page.waitForState('login');
|
||||
|
||||
expect(message.text).toContain('Notification sent!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<h5 class="vn-mb-md vn-mt-lg" translate>Recover password</h5>
|
||||
<vn-textfield
|
||||
label="Email"
|
||||
ng-model="$ctrl.email"
|
||||
label="User or recovery email"
|
||||
ng-model="$ctrl.user"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<div
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class Controller {
|
|||
|
||||
submit() {
|
||||
const params = {
|
||||
email: this.email
|
||||
user: this.user
|
||||
};
|
||||
|
||||
this.$http.post('Accounts/recoverPassword', params)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Recover password: Recuperar contraseña
|
||||
We will sent you an email to recover your password: Te enviaremos un correo para restablecer tu contraseña
|
||||
Notification sent!: ¡Notificación enviada!
|
||||
User or recovery email: Usuario o correo de recuperación
|
||||
|
|
Loading…
Reference in New Issue