Skip to content

Commit

Permalink
Update Routes.php
Browse files Browse the repository at this point in the history
The Routes.php now will use reserved routing from Auth.php
  • Loading branch information
mjamilasfihani committed Jul 8, 2022
1 parent 8babd47 commit 44bb889
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@

namespace Myth\Auth\Config;

use Myth\Auth\Config\Auth as AuthConfig;

// Myth:Auth routes file.
$routes->group('', ['namespace' => 'Myth\Auth\Controllers'], static function ($routes) {
// Load the reserved routes from Auth.php
$config = config(AuthConfig::class);
$reservedRoutes = $config->reservedRoutes;

// Login/out
$routes->get('login', 'AuthController::login', ['as' => 'login']);
$routes->post('login', 'AuthController::attemptLogin');
$routes->get('logout', 'AuthController::logout');
$routes->get($reservedRoutes['login'], 'Auth::login', ['as' => $reservedRoutes['login']]);
$routes->post($reservedRoutes['login'], 'Auth::attemptLogin');
$routes->get($reservedRoutes['logout'], 'Auth::logout');

// Registration
$routes->get('register', 'AuthController::register', ['as' => 'register']);
$routes->post('register', 'AuthController::attemptRegister');
$routes->get($reservedRoutes['register'], 'Auth::register', ['as' => $reservedRoutes['register']]);
$routes->post($reservedRoutes['register'], 'Auth::attemptRegister');

// Activation
$routes->get('activate-account', 'AuthController::activateAccount', ['as' => 'activate-account']);
$routes->get('resend-activate-account', 'AuthController::resendActivateAccount', ['as' => 'resend-activate-account']);
$routes->get($reservedRoutes['activate-account'], 'Auth::activateAccount', ['as' => $reservedRoutes['activate-account']]);
$routes->get($reservedRoutes['resend-activate-account'], 'Auth::resendActivateAccount', ['as' => $reservedRoutes['resend-activate-account']]);

// Forgot/Resets
$routes->get('forgot', 'AuthController::forgotPassword', ['as' => 'forgot']);
$routes->post('forgot', 'AuthController::attemptForgot');
$routes->get('reset-password', 'AuthController::resetPassword', ['as' => 'reset-password']);
$routes->post('reset-password', 'AuthController::attemptReset');
$routes->get($reservedRoutes['forgot'], 'Auth::forgotPassword', ['as' => $reservedRoutes['forgot']]);
$routes->post($reservedRoutes['forgot'], 'Auth::attemptForgot');
$routes->get($reservedRoutes['reset-password'], 'Auth::resetPassword', ['as' => $reservedRoutes['reset-password']]);
$routes->post($reservedRoutes['reset-password'], 'Auth::attemptReset');
});

0 comments on commit 44bb889

Please sign in to comment.