Completed
Push — master ( 03b333...573f2e )
by Abdelrahman
02:45
created

ForgotPasswordController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 5
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A showForgotPassword() 0 4 1
A processForgotPassword() 0 20 3
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Http\Controllers\Frontend;
17
18
use Illuminate\Support\Facades\Lang;
19
use Rinvex\Fort\Contracts\ResetBrokerContract;
20
use Rinvex\Fort\Http\Requests\PasswordResetRequest;
21
use Rinvex\Fort\Http\Controllers\AbstractController;
22
23
class ForgotPasswordController extends AbstractController
24
{
25
    /**
26
     * Create a new reset password controller instance.
27
     *
28
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
29
     */
30
    public function __construct()
31
    {
32
        $this->middleware($this->getGuestMiddleware(), ['except' => $this->middlewareWhitelist]);
33
    }
34
35
    /**
36
     * Show the password reset request form.
37
     *
38
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
39
     */
40
    public function showForgotPassword()
41
    {
42
        return view('rinvex.fort::password.forgot');
43
    }
44
45
    /**
46
     * Process the password reset request form.
47
     *
48
     * @param \Rinvex\Fort\Http\Requests\PasswordResetRequest $request
49
     *
50
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
51
     */
52
    public function processForgotPassword(PasswordResetRequest $request)
53
    {
54
        $result = app('rinvex.fort.resetter')->broker($this->getBroker())->sendResetLink($request->except(['_token']));
55
56
        switch ($result) {
57
            case ResetBrokerContract::LINK_SENT:
58
                return intend([
59
                    'intended' => route('home'),
60
                    'with'     => ['rinvex.fort.alert.success' => Lang::get($result)],
61
                ]);
62
63
            case ResetBrokerContract::INVALID_USER:
64
            default:
65
                return intend([
66
                    'back'       => true,
67
                    'withInput'  => $request->only('email'),
68
                    'withErrors' => ['email' => Lang::get($result)],
69
                ]);
70
        }
71
    }
72
}
73