Fix bin/publish: use correct .env path for rspade_system Fix bin/publish script: prevent grep exit code 1 from terminating script 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
1.5 KiB
PHP
Executable File
71 lines
1.5 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* CODING CONVENTION:
|
|
* This file follows the coding convention where variable_names and function_names
|
|
* use snake_case (underscore_wherever_possible).
|
|
*/
|
|
|
|
namespace App\RSpade\Core\Auth;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
use App\RSpade\Core\Session\Session;
|
|
|
|
/**
|
|
* RSX Authentication service
|
|
*
|
|
* Provides authentication logic for login/logout.
|
|
* All session management is handled by the Session class directly.
|
|
*/
|
|
class RsxAuth
|
|
{
|
|
/**
|
|
* Attempt to authenticate a user
|
|
*
|
|
* @param array $credentials
|
|
* @return bool
|
|
*/
|
|
public static function attempt(array $credentials)
|
|
{
|
|
$email = $credentials['email'] ?? null;
|
|
$password = $credentials['password'] ?? null;
|
|
|
|
if (!$email || !$password) {
|
|
return false;
|
|
}
|
|
|
|
// Use model without eager loading
|
|
$user = User_Model::where('email', $email)->first();
|
|
|
|
if (!$user || !Hash::check($password, $user->password)) {
|
|
return false;
|
|
}
|
|
|
|
return self::login($user);
|
|
}
|
|
|
|
/**
|
|
* Log in a user and create session
|
|
*
|
|
* @param User_Model $user
|
|
* @return bool
|
|
*/
|
|
public static function login(User_Model $user)
|
|
{
|
|
// Use Session to set the user (will create session if needed)
|
|
Session::set_user($user);
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Log out the current user
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function logout()
|
|
{
|
|
// Use Session to logout
|
|
Session::logout();
|
|
}
|
|
}
|