uo; default: return parent::__get($key); } } /** * Handle user logins * * @return bool * @throws ActionMissingInputsException */ public function handle(): bool { parent::init(); $this->uo = new User; $this->uo->name = $this->fields_input->where('name','FULLNAME')->first()->value; $this->uo->email = $this->fields_input->where('name','EMAIL')->first()->value; $this->uo->email_verified_at = Carbon::now(); $this->uo->password = Hash::make($x=$this->fields_input->where('name','PASS')->first()->value); $this->uo->active = TRUE; $this->uo->last_on = Carbon::now(); $this->uo->alias = $this->fields_input->where('name','USER')->first()->value; $this->uo->save(); return TRUE; } public function preSubmitField(Server $server,Field $field): ?string { switch ($field->name) { // Send a token case 'EMAIL': // Make sure we got an email address if (Validator::make(['email'=>$field->value],[ 'email'=>'email', ])->fails()) { return 'INVALID EMAIL ADDRESS'; } // See if the requested email already exists if (User::where('email',$field->value)->exists()) return 'USER ALREADY EXISTS'; Log::info(sprintf('Sending token to [%s]',$field->value)); $server->sendBaseline(RED.'SENDING TOKEN...'); $this->token = sprintf('%06.0f',rand(0,999999)); $sent = Mail::to($field->value)->send(new SendToken($this->token)); $server->sendBaseline(RED.'SENT'); break; case 'USER': if (str_contains($field->value,' ')) return 'NO SPACES IN USER NAMES'; // See if the requested username already exists if (User::where('alias',$field->value)->exists()) return 'USER ALREADY EXISTS'; // Clear the baseline from EMAIL entry $server->sendBaseline(''); break; case 'TOKEN': if ($field->value !== $this->token) return 'INVALID TOKEN'; break; } return NULL; } }