Skip to content

Commit

Permalink
Merge pull request #143 from barryvdh/patch-2
Browse files Browse the repository at this point in the history
[2.x] Add namespace check to Auth routes
  • Loading branch information
taylorotwell authored Sep 9, 2020
2 parents 8401dd2 + 2d6a377 commit 2ccaa3b
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions src/AuthRouteMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,42 @@ class AuthRouteMethods
public function auth()
{
return function ($options = []) {
// Login Routes...
if ($options['login'] ?? true) {
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
}

// Logout Routes...
if ($options['logout'] ?? true) {
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
}
$namespace = class_exists($this->prependGroupNamespace('Auth\LoginController')) ? null : 'App\Http\Controllers';

// Registration Routes...
if ($options['register'] ?? true) {
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
}
$this->group(['namespace' => $namespace], function() use($options) {
// Login Routes...
if ($options['login'] ?? true) {
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
}

// Password Reset Routes...
if ($options['reset'] ?? true) {
$this->resetPassword();
}
// Logout Routes...
if ($options['logout'] ?? true) {
$this->post('logout', 'Auth\LoginController@logout')->name('logout');
}

// Password Confirmation Routes...
if ($options['confirm'] ??
class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) {
$this->confirmPassword();
}
// Registration Routes...
if ($options['register'] ?? true) {
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
}

// Email Verification Routes...
if ($options['verify'] ?? false) {
$this->emailVerification();
}
// Password Reset Routes...
if ($options['reset'] ?? true) {
$this->resetPassword();
}

// Password Confirmation Routes...
if ($options['confirm'] ??
class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) {
$this->confirmPassword();
}

// Email Verification Routes...
if ($options['verify'] ?? false) {
$this->emailVerification();
}
});
};
}

Expand Down

0 comments on commit 2ccaa3b

Please sign in to comment.