Minor code cleanup

This commit is contained in:
rijkvanzanten
2020-12-16 16:57:26 -05:00
parent 651263cbde
commit bbae89d633
2 changed files with 5 additions and 6 deletions

View File

@@ -115,15 +115,14 @@ export class UsersService extends ItemsService {
}
}
async requestPasswordReset(email: string, url: string) {
async requestPasswordReset(email: string, url: string | null) {
const user = await this.knex.select('id').from('directus_users').where({ email }).first();
if (!user) throw new ForbiddenException();
const payload = { email, scope: 'password-reset' };
const token = jwt.sign(payload, env.SECRET as string, { expiresIn: '1d' });
let acceptURL = env.PUBLIC_URL + '/admin/reset-password?token=' + token
if(url && url !== '') acceptURL = url + '?token=' + token
const acceptURL = url ? `${url}?token=${token}` : `${env.PUBLIC_URL}/admin/reset-password?token=${token}`;
await sendPasswordResetMail(email, acceptURL);
}