Moved registration processing into Frame/Action
This commit is contained in:
@@ -16,10 +16,10 @@ class Login extends Action
|
||||
* @param array $fielddata
|
||||
* @return bool
|
||||
*/
|
||||
public function handle(array $fielddata)
|
||||
public function handle()
|
||||
{
|
||||
// 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))
|
||||
if (count($this->so->fo->getFieldData()) != 2 OR ! $this->so->fo->getFieldDataId(0) OR ! $this->so->fo->getFieldDataId(1))
|
||||
{
|
||||
$this->mode = 2; // MODE_FIELD
|
||||
// $this->action = 2; // ACTION_GOTO
|
||||
@@ -30,7 +30,7 @@ class Login extends Action
|
||||
}
|
||||
|
||||
try {
|
||||
$this->uo = User::where('login',array_get($fielddata,0))->firstOrFail();
|
||||
$this->uo = User::where('login',$this->so->fo->getFieldDataId(0))->firstOrFail();
|
||||
|
||||
} catch (ModelNotFoundException $e) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'USER NOT FOUND, TRY AGAIN *00');
|
||||
@@ -38,7 +38,7 @@ class Login extends Action
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($this->uo->password != array_get($fielddata,1))
|
||||
if ($this->uo->password != $this->so->fo->getFieldDataId(1))
|
||||
{
|
||||
$this->uo = new User;
|
||||
$this->so->sendBaseline($this->so->co,RED.'INVALID PASSWORD, TRY AGAIN *00');
|
||||
|
47
app/Classes/Frame/Action/Register.php
Normal file
47
app/Classes/Frame/Action/Register.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Frame\Action;
|
||||
|
||||
use App\User;
|
||||
|
||||
use App\Classes\Frame\Action;
|
||||
|
||||
/**
|
||||
* Class Register
|
||||
* This handles the data received for account registration
|
||||
*
|
||||
* @package App\Classes\Frame\Action
|
||||
*/
|
||||
class Register extends Action
|
||||
{
|
||||
/**
|
||||
* Handle user logins
|
||||
*
|
||||
* @param array $fielddata
|
||||
* @return bool
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$o = new User;
|
||||
|
||||
try {
|
||||
$o->login = $this->so->fo->getFieldDataId(0);
|
||||
$o->name = $this->so->fo->getFieldDataId(1);
|
||||
$o->email = $this->so->fo->getFieldDataId(2);
|
||||
$o->password = $this->so->fo->getFieldDataId(3);
|
||||
$o->location = $this->so->fo->getFieldDataId(5);
|
||||
|
||||
$o->save();
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'ACCOUNT CREATED, PRESS '.HASH.' TO CONTINUE...'.WHITE);
|
||||
$this->state['action'] = ACTION_NEXT;
|
||||
|
||||
// Add to CUG 0
|
||||
$o->cugs()->attach(0);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'SOMETHING WENT WRONG...'.WHITE);
|
||||
$this->so->log('error',$e->getMessage());
|
||||
$this->state['action'] = ACTION_RELOAD;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user