RemindersController::getReset()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
3
class RemindersController extends Controller {
0 ignored issues
show
Bug introduced by
The type Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
5
	/**
6
	 * Display the password reminder view.
7
	 *
8
	 * @return Response
9
	 */
10
	public function getRemind()
11
	{
12
		return View::make('templates/password_reset/remind');
13
	}
14
15
	/**
16
	 * Handle a POST request to remind a user of their password.
17
	 *
18
	 * @return Response
19
	 */
20
	public function postRemind()
21
	{
22
                $response = Password::remind(Input::only('email'), function($message)
0 ignored issues
show
Bug introduced by
The type Input was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
                {
24
                        $message->subject('Password Reset');
25
                });
26
27
		switch ($response)
28
		{
29
			case Password::INVALID_USER:
30
				return Redirect::back()->withErrors(['error']);
31
32
			case Password::REMINDER_SENT:
33
				return Redirect::back()->withErrors(['success']);
34
		}
35
	}
36
37
	/**
38
	 * Display the password reset view for the given token.
39
	 *
40
	 * @param  string  $token
41
	 * @return Response
42
	 */
43
	public function getReset($token = null)
44
	{
45
		if (is_null($token)) App::abort(404);
46
47
		return View::make('templates/password_reset/reset')->with('token', $token);
48
	}
49
50
	/**
51
	 * Handle a POST request to reset a user's password.
52
	 *
53
	 * @return Response
54
	 */
55
	public function postReset()
56
	{
57
		$credentials = Input::only(
58
			'email', 'password', 'password_confirmation', 'token'
59
		);
60
61
		$response = Password::reset($credentials, function($user, $password)
62
		{
63
			$user->password = Hash::make($password);
64
65
			$user->save();
66
		});
67
68
		switch ($response)
69
		{
70
			case Password::INVALID_PASSWORD:
71
			case Password::INVALID_TOKEN:
72
			case Password::INVALID_USER:
73
				return Redirect::back()->withErrors(Lang::get($response) );
74
75
			case Password::PASSWORD_RESET:
76
				return Redirect::back()->withErrors("Password has been reset! <a class='btn btn-default' href='/'>Click here to login</a>");
77
		}
78
	}
79
80
}
81