Skip to content

Commit

Permalink
Change auth login controller structure
Browse files Browse the repository at this point in the history
  • Loading branch information
puleeno committed Apr 20, 2024
1 parent b150864 commit a75027d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
35 changes: 19 additions & 16 deletions app/Http/Controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@

namespace App\Http\Controllers;

use Quagga\Quagga\Foundation\Auth\AuthenticatesUsers;
use Slim\Psr7\Request;

class LoginController
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;


/**
* Handle an authentication attempt.
* Setting redirect URL after login successful
*
* @return string
*/
public function authenticate(Request $request): RedirectResponse
public function redirectTo()
{
$credentials = $request->validate([
'email' => ['required', 'email'],
'password' => ['required'],
]);

if (Auth::attempt($credentials)) {
$request->session()->regenerate();

return redirect()->intended('dashboard');
}

return back()->withErrors([
'email' => 'The provided credentials do not match our records.',
])->onlyInput('email');
return '/';
}
}
3 changes: 2 additions & 1 deletion app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ function get_active_theme_url($theme = null)
}

if (!function_exists('config')) {
function config($name, $defaultValue = null) {
function config($name, $defaultValue = null)
{
return Helper::getConfig($name, $defaultValue);
}
}
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$group->get('/{id}', ViewUserAction::class);
});

$app->any(config('auth.login.path'), [LoginController::class, 'auth']);
$app->any(config('auth.login.path'), [LoginController::class, 'login']);

$app->any(
'/',
Expand Down

0 comments on commit a75027d

Please sign in to comment.