Issues (25)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/Http/Controllers/Auth/PasswordController.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace App\Http\Controllers\Auth;
2
3
use App\Events\Users\RequestedResetPasswordLink;
4
use App\Events\Users\ResetPassword;
5
use App\Exceptions\Common\ValidationException;
6
use App\Exceptions\Users\TokenNotValidException;
7
use App\Http\Controllers\Controller;
8
use App\Models\User;
9
use App\Notifications\ResetPasswordNotification;
10
use Illuminate\Contracts\Auth\PasswordBroker;
11
use Illuminate\Database\Eloquent\ModelNotFoundException;
12
use Illuminate\Foundation\Auth\RedirectsUsers;
13
use Illuminate\Http\Request;
14
15
class PasswordController extends Controller
16
{
17
    use RedirectsUsers;
18
19
    /**
20
     * Create a new password controller instance.
21
     */
22 4
    public function __construct()
23
    {
24 4
        $this->middleware('guest');
25 4
    }
26
27
    /**
28
     * Display the form to request a password reset link.
29
     *
30
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
31
     */
32
    public function requestPasswordResetLink()
33
    {
34
        return view('password/email');
35
    }
36
37
    /**
38
     * Send a password reset link to the given email's owner, via email.
39
     *
40
     * @param \Illuminate\Http\Request $request
41
     *
42
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
43
     * @throws \App\Exceptions\Common\ValidationException
44
     */
45 2
    public function sendPasswordResetLink(Request $request)
46
    {
47 2
        $validator = app('validator')->make($request->all(), [
48 2
            'email' => 'required|email|max:255'
49
        ]);
50 2
        if ($validator->fails()) {
51 1
            throw new ValidationException($validator);
52
        }
53
54 2
        $user = User::whereEmail($request->only('email'))->first();
55 2
        if (is_null($user)) {
56 1
            throw new ModelNotFoundException(trans('passwords.user'));
57
        }
58
59 1
        $user->notify(new ResetPasswordNotification($token = app('auth.password.broker')->createToken($user)));
60
61 1
        event(new RequestedResetPasswordLink($user));
62
63 1
        if ($request->expectsJson()) {
64 1
            $response = ['message' => trans('passwords.sent')];
65 1
            if (env('APP_ENV') == 'testing') {
66 1
                $response['token'] = $token;
67
            }
68
69 1
            return response()->json($response);
70
        }
71
72
        return redirect()->back()->with('message', trans('passwords.sent'));
73
    }
74
75
    /**
76
     * Display the password reset view for the given token.
77
     *
78
     * @param \Illuminate\Http\Request $request
79
     * @param string                   $token
80
     *
81
     * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View|\Illuminate\Contracts\View\Factory
82
     */
83
    public function showPasswordResetForm(Request $request, $token = null)
84
    {
85
        if (is_null($token)) {
86
            if ($request->expectsJson()) {
87
                throw new TokenNotValidException();
88
            }
89
90
            return view('password/reset')->withErrors(['token' => trans(PasswordBroker::INVALID_TOKEN)]);
91
        }
92
93
        if ($request->expectsJson()) {
94
            return response()->json(['token' => $token]);
95
        }
96
97
        return view('password/reset')->with('token', $token);
98
    }
99
100
    /**
101
     * Reset the password through password-reset-token and email provided.
102
     *
103
     * @param \Illuminate\Http\Request $request
104
     *
105
     * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
106
     * @throws \App\Exceptions\Common\ValidationException
107
     */
108 2
    public function resetPassword(Request $request)
109
    {
110 2
        $validator = app('validator')->make($request->all(), [
111 2
            'token' => 'required|string',
112 2
            'email' => 'required|email|max:255',
113 2
            'password' => 'required|confirmed|min:' . app('config')->get('auth.passwords.users.min_length')
114
        ]);
115 2
        if ($validator->fails()) {
116 1
            throw new ValidationException($validator);
117
        }
118
119 2
        $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
120
121 2
        $passwordBroker = app('auth.password.broker');
122 2
        $response = $passwordBroker->reset(
123 2
            $credentials, function (User $user, $password) {
124 1
            $user->password = app('hash')->make($password);
125 1
            $user->save();
126 1
            app('auth.driver')->login($user);
127 2
        });
128
129
        switch ($response) {
130 2
            case $passwordBroker::INVALID_USER:
131 1
                throw new ModelNotFoundException(trans($response));
132
                break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
133 2
            case $passwordBroker::INVALID_TOKEN:
134 1
                throw new TokenNotValidException(trans($response));
135
                break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
136
        }
137
138 1
        event(new ResetPassword(app('auth.driver')->user()));
139
140 1
        if ($request->expectsJson()) {
141 1
            return response()->json(['message' => trans('passwords.reset')]);
142
        }
143
144
        return redirect($this->redirectPath())->with('message', trans('passwords.reset'));
145
    }
146
}
147