Skip to content

Commit 2ccaa3b

Browse files
authored
Merge pull request #143 from barryvdh/patch-2
[2.x] Add namespace check to Auth routes
2 parents 8401dd2 + 2d6a377 commit 2ccaa3b

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

src/AuthRouteMethods.php

+32-28
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,42 @@ class AuthRouteMethods
1313
public function auth()
1414
{
1515
return function ($options = []) {
16-
// Login Routes...
17-
if ($options['login'] ?? true) {
18-
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
19-
$this->post('login', 'Auth\LoginController@login');
20-
}
21-
22-
// Logout Routes...
23-
if ($options['logout'] ?? true) {
24-
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
25-
}
16+
$namespace = class_exists($this->prependGroupNamespace('Auth\LoginController')) ? null : 'App\Http\Controllers';
2617

27-
// Registration Routes...
28-
if ($options['register'] ?? true) {
29-
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
30-
$this->post('register', 'Auth\RegisterController@register');
31-
}
18+
$this->group(['namespace' => $namespace], function() use($options) {
19+
// Login Routes...
20+
if ($options['login'] ?? true) {
21+
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
22+
$this->post('login', 'Auth\LoginController@login');
23+
}
3224

33-
// Password Reset Routes...
34-
if ($options['reset'] ?? true) {
35-
$this->resetPassword();
36-
}
25+
// Logout Routes...
26+
if ($options['logout'] ?? true) {
27+
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
28+
}
3729

38-
// Password Confirmation Routes...
39-
if ($options['confirm'] ??
40-
class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) {
41-
$this->confirmPassword();
42-
}
30+
// Registration Routes...
31+
if ($options['register'] ?? true) {
32+
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
33+
$this->post('register', 'Auth\RegisterController@register');
34+
}
4335

44-
// Email Verification Routes...
45-
if ($options['verify'] ?? false) {
46-
$this->emailVerification();
47-
}
36+
// Password Reset Routes...
37+
if ($options['reset'] ?? true) {
38+
$this->resetPassword();
39+
}
40+
41+
// Password Confirmation Routes...
42+
if ($options['confirm'] ??
43+
class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) {
44+
$this->confirmPassword();
45+
}
46+
47+
// Email Verification Routes...
48+
if ($options['verify'] ?? false) {
49+
$this->emailVerification();
50+
}
51+
});
4852
};
4953
}
5054

0 commit comments

Comments
 (0)