- Implement AuthController with login/logout functionality - Create UsersModel with bcrypt password hashing - Add AuthFilter to protect all application routes - Create login page with error handling - Add users database migration with email/username fields - Rename ResultComments to TestComments for consistency - Update all routes to require authentication filter - Enhance EntryApiController with comment deletion and better error handling - Update seeder to include demo users and improved test data - Fix BaseController to handle auth sessions properly - Update entry views (daily/monthly) with new API endpoints - Update layout with logout button and user info display - Refactor control test index view for better organization
39 lines
936 B
PHP
39 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Models\Auth;
|
|
|
|
use App\Models\BaseModel;
|
|
|
|
class UsersModel extends BaseModel
|
|
{
|
|
protected $table = 'master_users';
|
|
protected $primaryKey = 'user_id';
|
|
protected $allowedFields = ['username', 'password', 'remember_token'];
|
|
protected $useSoftDeletes = true;
|
|
protected $useTimestamps = true;
|
|
|
|
public function findByUsername($username)
|
|
{
|
|
return $this->where('username', $username)->first();
|
|
}
|
|
|
|
public function verifyPassword($userId, $password)
|
|
{
|
|
$user = $this->find($userId);
|
|
if (!$user) {
|
|
return false;
|
|
}
|
|
return password_verify($password, $user['password']);
|
|
}
|
|
|
|
public function setRememberToken($userId, $token)
|
|
{
|
|
return $this->update($userId, ['remember_token' => $token]);
|
|
}
|
|
|
|
public function findByRememberToken($token)
|
|
{
|
|
return $this->where('remember_token', $token)->first();
|
|
}
|
|
}
|