Login working
This commit is contained in:
56
app/Classes/Frame/Action/Login.php
Normal file
56
app/Classes/Frame/Action/Login.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Frame\Action;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\Frame\Action;
|
||||
|
||||
class Login extends Action
|
||||
{
|
||||
/**
|
||||
* Handle user logins
|
||||
*
|
||||
* @param array $fielddata
|
||||
* @return bool
|
||||
*/
|
||||
public function handle(array $fielddata)
|
||||
{
|
||||
// First field data element is user, the second is the password
|
||||
if (count($fielddata) != 2 OR ! array_get($fielddata,0) OR ! array_get($fielddata,1))
|
||||
{
|
||||
$this->mode = 2; // MODE_FIELD
|
||||
// $this->action = 2; // ACTION_GOTO
|
||||
|
||||
$this->so->sendBaseline($this->so->client(),RED.'INVALID DETAILS, TRY AGAIN *00');
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->uo = User::where('login',array_get($fielddata,0))->firstOrFail();
|
||||
|
||||
} catch (ModelNotFoundException $e) {
|
||||
$this->so->sendBaseline($this->so->client(),RED.'USER NOT FOUND, TRY AGAIN *00');
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($this->uo->password != array_get($fielddata,1))
|
||||
{
|
||||
$this->uo = new User;
|
||||
$this->so->sendBaseline($this->so->client(),RED.'INVALID PASSWORD, TRY AGAIN *00');
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->page = ['frame'=>1,'index'=>'a']; // @todo Get from DB.
|
||||
|
||||
$this->action = 2; // ACTION_GOTO
|
||||
$this->mode = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user