Internal rework pending editframe
This commit is contained in:
@@ -12,7 +12,6 @@ use Illuminate\Support\Facades\Validator;
|
||||
* Class Register handles registration
|
||||
*
|
||||
* @todo REMOVE the force .WHITE at the end of each sendBaseline()
|
||||
*
|
||||
* @package App\Classes\Control
|
||||
*/
|
||||
class Register extends Control
|
||||
@@ -21,7 +20,7 @@ class Register extends Control
|
||||
|
||||
protected function boot()
|
||||
{
|
||||
$this->so->sendBaseline($this->so->client(),GREEN.'Select User Name'.WHITE);
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Select User Name'.WHITE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,124 +36,114 @@ class Register extends Control
|
||||
*/
|
||||
public function handle(string $read,array $current=[])
|
||||
{
|
||||
// Ignore CR
|
||||
if ($read == CR)
|
||||
return '';
|
||||
|
||||
// If we got a # we'll be completing field input.
|
||||
if ($read == HASH OR $read == LF) {
|
||||
// Does our field have data...
|
||||
if (array_get($current['fielddata'],$current['fieldnum'])) {
|
||||
switch ($current['fieldnum']) {
|
||||
// Username
|
||||
case 0:
|
||||
// See if the requested username already exists
|
||||
if (User::where('login', $current['fielddata'][$current['fieldnum']])->exists()) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'USER ALREADY EXISTS'.WHITE);
|
||||
|
||||
// Our registration page
|
||||
// @todo get this from the DB
|
||||
if ($current['page']['frame'] == '981') {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Does our field have data...
|
||||
if (array_get($current['fielddata'],$current['fieldnum'])) {
|
||||
switch ($current['fieldnum']) {
|
||||
// Username
|
||||
case 0:
|
||||
// See if the requested username already exists
|
||||
if (User::where('login', $current['fielddata'][$current['fieldnum']])->exists()) {
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'USER ALREADY EXISTS'.WHITE);
|
||||
$this->data['user'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Enter Real Name'.WHITE);
|
||||
|
||||
return '';
|
||||
}
|
||||
break;
|
||||
|
||||
$this->data['user'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'Enter Real Name'.WHITE);
|
||||
// Real Name
|
||||
case 1:
|
||||
$this->data['name'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Enter Email Address'.WHITE);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
// Real Name
|
||||
case 1:
|
||||
$this->data['name'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'Enter Email Address'.WHITE);
|
||||
// Email Address
|
||||
case 2:
|
||||
if (Validator::make(['email'=>$current['fielddata'][$current['fieldnum']]],[
|
||||
'email'=>'email',
|
||||
])->fails()) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'INVALID EMAIL ADDRESS'.WHITE);
|
||||
|
||||
break;
|
||||
return '';
|
||||
};
|
||||
|
||||
// Email Address
|
||||
case 2:
|
||||
if (Validator::make(['email'=>$current['fielddata'][$current['fieldnum']]],[
|
||||
'email'=>'email',
|
||||
])->fails()) {
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'INVALID EMAIL ADDRESS'.WHITE);
|
||||
// See if the requested email already exists
|
||||
if (User::where('email', $current['fielddata'][$current['fieldnum']])->exists()) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'USER ALREADY EXISTS'.WHITE);
|
||||
|
||||
return '';
|
||||
};
|
||||
return '';
|
||||
}
|
||||
|
||||
// See if the requested email already exists
|
||||
if (User::where('email', $current['fielddata'][$current['fieldnum']])->exists()) {
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'USER ALREADY EXISTS'.WHITE);
|
||||
$this->data['email'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->data['token'] = sprintf('%06.0f',rand(0,999999));
|
||||
|
||||
return '';
|
||||
}
|
||||
$this->so->sendBaseline($this->so->co,YELLOW.'PROCESSING...'.WHITE);
|
||||
Mail::to($this->data['email'])->sendNow(new SendToken($this->data['token']));
|
||||
|
||||
$this->data['email'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->data['token'] = sprintf('%06.0f',rand(0,999999));
|
||||
if (Mail::failures()) {
|
||||
dump('Failure?');
|
||||
|
||||
$this->so->sendBaseline($this->so->client(), YELLOW . 'PROCESSING...'.WHITE);
|
||||
Mail::to($this->data['email'])->sendNow(new SendToken($this->data['token']));
|
||||
dump(Mail::failures());
|
||||
}
|
||||
|
||||
if (Mail::failures()) {
|
||||
dump('Failure?');
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Enter Password'.WHITE);
|
||||
|
||||
dump(Mail::failures());
|
||||
}
|
||||
break;
|
||||
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'Enter Password'.WHITE);
|
||||
// Enter Password
|
||||
case 3:
|
||||
$this->data['password'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Confirm Password'.WHITE);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
// Enter Password
|
||||
case 3:
|
||||
$this->data['password'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'Confirm Password'.WHITE);
|
||||
// Confirm Password
|
||||
case 4:
|
||||
if ($this->data['password'] !== $current['fielddata'][$current['fieldnum']]) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'PASSWORD DOESNT MATCH, *09 TO START AGAIN'.WHITE);
|
||||
|
||||
break;
|
||||
return '';
|
||||
}
|
||||
|
||||
// Confirm Password
|
||||
case 4:
|
||||
if ($this->data['password'] !== $current['fielddata'][$current['fieldnum']]) {
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'PASSWORD DOESNT MATCH, *09 TO START AGAIN'.WHITE);
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Enter Location'.WHITE);
|
||||
|
||||
return '';
|
||||
}
|
||||
break;
|
||||
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'Enter Location'.WHITE);
|
||||
// Enter Location
|
||||
case 5:
|
||||
$this->data['location'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->co,GREEN.'Enter TOKEN emailed to you'.WHITE);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
// Enter Location
|
||||
case 5:
|
||||
$this->data['location'] = $current['fielddata'][$current['fieldnum']];
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'Enter TOKEN emailed to you'.WHITE);
|
||||
// Enter Token
|
||||
case 6:
|
||||
if ($this->data['token'] !== $current['fielddata'][$current['fieldnum']]) {
|
||||
$this->so->sendBaseline($this->so->co,RED.'TOKEN DOESNT MATCH, *09 TO START AGAIN'.WHITE);
|
||||
|
||||
break;
|
||||
return '';
|
||||
}
|
||||
|
||||
// Enter Token
|
||||
case 6:
|
||||
if ($this->data['token'] !== $current['fielddata'][$current['fieldnum']]) {
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'TOKEN DOESNT MATCH, *09 TO START AGAIN'.WHITE);
|
||||
break;
|
||||
|
||||
return '';
|
||||
}
|
||||
default:
|
||||
$this->so->sendBaseline($this->so->co,RED.'HUH?');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'HUH?');
|
||||
}
|
||||
} else {
|
||||
// If we are MODE_BL, we need to return the HASH, otherwise nothing.
|
||||
if (in_array($this->state['mode'],[MODE_BL,MODE_SUBMITRF,MODE_RFNOTSENT])) {
|
||||
return $read;
|
||||
|
||||
} else {
|
||||
// If we are MODE_BL, we need to return the HASH, otherwise nothing.
|
||||
if (in_array($this->state['mode'],[MODE_BL,MODE_SUBMITRF,MODE_RFNOTSENT])) {
|
||||
return $read;
|
||||
$this->so->sendBaseline($this->so->co,RED.'FIELD REQUIRED...'.WHITE);
|
||||
|
||||
} else {
|
||||
$this->so->sendBaseline($this->so->client(), RED . 'FIELD REQUIRED...'.WHITE);
|
||||
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,14 +163,14 @@ class Register extends Control
|
||||
$o->location = $this->data['location'];
|
||||
|
||||
$o->save();
|
||||
$this->so->sendBaseline($this->so->client(), GREEN . 'ACCOUNT CREATED, PRESS '.HASH.' TO CONTINUE...'.WHITE);
|
||||
$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->client(), RED . 'SOMETHING WENT WRONG...'.WHITE);
|
||||
$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