BBS ported from vbbs

This commit is contained in:
2023-08-10 12:17:01 +10:00
parent 48ed6eb8ea
commit c9688ef373
34 changed files with 5208 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Classes\BBS\Frame\Action;
use Illuminate\Support\Facades\Hash;
use App\Classes\BBS\Exceptions\{ActionMissingInputsException,InvalidPasswordException};
use App\Classes\BBS\Frame\{Action,Field};
use App\Classes\BBS\Server;
use App\Models\User;
class Login extends Action
{
protected const fields = ['USER','PASS'];
public function __get(string $key): mixed
{
switch ($key) {
case 'user': return $this->uo;
default:
return parent::__get($key);
}
}
/**
* Handle user logins
*
* @return bool
* @throws ActionMissingInputsException
* @throws InvalidPasswordException
*/
public function handle(): bool
{
parent::init();
$this->uo = User::where('name',$this->USER)->orWhere('alias',$this->USER)->firstOrFail();
if (! Hash::check($this->PASS,$this->uo->password))
throw new InvalidPasswordException(sprintf('Password doesnt match for [%s]',$this->USER));
return TRUE;
}
public function preSubmitField(Server $server,Field $field): ?string
{
// Noop
return NULL;
}
}