diff options
author | 2024-02-10 18:19:14 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | 7584d2d7a7110aef0331ebfa178b2295842c59fa (patch) | |
tree | 900cd71237e6231b57936fcce77ff229cd459041 /app/Controllers/Http/Dashboard/ForgotPasswordController.ts | |
parent | upgrade recipes submodule (diff) | |
download | ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.gz ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.zst ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.zip |
refactor: project maintenance
- work in progress
Diffstat (limited to 'app/Controllers/Http/Dashboard/ForgotPasswordController.ts')
-rw-r--r-- | app/Controllers/Http/Dashboard/ForgotPasswordController.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/Controllers/Http/Dashboard/ForgotPasswordController.ts b/app/Controllers/Http/Dashboard/ForgotPasswordController.ts index da05bbd..f7b1d0e 100644 --- a/app/Controllers/Http/Dashboard/ForgotPasswordController.ts +++ b/app/Controllers/Http/Dashboard/ForgotPasswordController.ts | |||
@@ -1,41 +1,41 @@ | |||
1 | import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; | 1 | import type { HttpContext } from '@adonisjs/core/http' |
2 | import { schema, rules, validator } from '@ioc:Adonis/Core/Validator'; | 2 | import { schema, rules, validator } from '@adonisjs/validator' |
3 | import User from 'App/Models/User'; | 3 | import User from '#app/Models/User' |
4 | 4 | ||
5 | export default class ForgotPasswordController { | 5 | export default class ForgotPasswordController { |
6 | /** | 6 | /** |
7 | * Display the forgot password form | 7 | * Display the forgot password form |
8 | */ | 8 | */ |
9 | public async show({ view }: HttpContextContract) { | 9 | public async show({ view }: HttpContext) { |
10 | return view.render('dashboard/forgotPassword'); | 10 | return view.render('dashboard/forgotPassword') |
11 | } | 11 | } |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Send forget password email to user | 14 | * Send forget password email to user |
15 | */ | 15 | */ |
16 | public async forgotPassword({ view, request }: HttpContextContract) { | 16 | public async forgotPassword({ view, request }: HttpContext) { |
17 | try { | 17 | try { |
18 | await validator.validate({ | 18 | await validator.validate({ |
19 | schema: schema.create({ | 19 | schema: schema.create({ |
20 | mail: schema.string([rules.email(), rules.required()]), | 20 | mail: schema.string([rules.email(), rules.required()]), |
21 | }), | 21 | }), |
22 | data: request.only(['mail']), | 22 | data: request.only(['mail']), |
23 | }); | 23 | }) |
24 | } catch { | 24 | } catch { |
25 | return view.render('others/message', { | 25 | return view.render('others/message', { |
26 | heading: 'Cannot reset your password', | 26 | heading: 'Cannot reset your password', |
27 | text: 'Please enter a valid email address', | 27 | text: 'Please enter a valid email address', |
28 | }); | 28 | }) |
29 | } | 29 | } |
30 | 30 | ||
31 | try { | 31 | try { |
32 | const user = await User.findByOrFail('email', request.input('mail')); | 32 | const user = await User.findByOrFail('email', request.input('mail')) |
33 | await user.forgotPassword(); | 33 | await user.forgotPassword() |
34 | } catch {} | 34 | } catch {} |
35 | 35 | ||
36 | return view.render('others/message', { | 36 | return view.render('others/message', { |
37 | heading: 'Reset password', | 37 | heading: 'Reset password', |
38 | text: 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.', | 38 | text: 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.', |
39 | }); | 39 | }) |
40 | } | 40 | } |
41 | } | 41 | } |