Add 100+ automated unit tests from .expect file specifications Add session system test Add rsx:constants:regenerate command test Add rsx:logrotate command test Add rsx:clean command test Add rsx:manifest:stats command test Add model enum system test Add model mass assignment prevention test Add rsx:check command test Add migrate:status command test 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
73 lines
1.7 KiB
PHP
73 lines
1.7 KiB
PHP
<?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\Models\Login_User_Model;
|
|
use App\RSpade\Core\Session\Session;
|
|
|
|
/**
|
|
* RSX Authentication service
|
|
*
|
|
* Provides authentication logic for login/logout.
|
|
* Authenticates against login_users table (authentication identity).
|
|
* 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;
|
|
}
|
|
|
|
// Authenticate against login_users table (authentication identity)
|
|
$login_user = Login_User_Model::where('email', $email)->first();
|
|
|
|
if (!$login_user || !Hash::check($password, $login_user->password)) {
|
|
return false;
|
|
}
|
|
|
|
return self::login($login_user);
|
|
}
|
|
|
|
/**
|
|
* Log in a user and create session
|
|
*
|
|
* @param Login_User_Model $login_user
|
|
* @return bool
|
|
*/
|
|
public static function login(Login_User_Model $login_user)
|
|
{
|
|
// Use Session to set the login user (will create session if needed)
|
|
Session::set_login_user_id($login_user->id);
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Log out the current user
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function logout()
|
|
{
|
|
// Use Session to logout
|
|
Session::logout();
|
|
}
|
|
}
|