diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2024-02-10 18:19:14 -0700 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2024-02-17 21:51:20 +0530 |
commit | a61e73c33b2e80d5af58e3dcfa2efe74245cd065 (patch) | |
tree | d5343ad245b4156662920896dedf14d9284051f8 /app/Controllers/Http/Dashboard/ForgotPasswordController.ts | |
parent | upgrade node to 20.11.1 and other minor versions for pkgs (#104) (diff) | |
download | ferdium-server-a61e73c33b2e80d5af58e3dcfa2efe74245cd065.tar.gz ferdium-server-a61e73c33b2e80d5af58e3dcfa2efe74245cd065.tar.zst ferdium-server-a61e73c33b2e80d5af58e3dcfa2efe74245cd065.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 | } |