Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/SignupController.php
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function init(Request $request) | ||||
} | } | ||||
if (!empty($errors)) { | if (!empty($errors)) { | ||||
return response()->json(['status' => 'error', 'errors' => $errors], 422); | return response()->json(['status' => 'error', 'errors' => $errors], 422); | ||||
} | } | ||||
// Generate the verification code | // Generate the verification code | ||||
$code = SignupCode::create([ | $code = SignupCode::create([ | ||||
'data' => [ | |||||
'email' => $request->email, | 'email' => $request->email, | ||||
'first_name' => $request->first_name, | 'first_name' => $request->first_name, | ||||
'last_name' => $request->last_name, | 'last_name' => $request->last_name, | ||||
'plan' => $request->plan, | 'plan' => $request->plan, | ||||
'voucher' => $request->voucher, | 'voucher' => $request->voucher, | ||||
] | |||||
]); | ]); | ||||
// Send email/sms message | // Send email/sms message | ||||
if ($is_phone) { | if ($is_phone) { | ||||
SignupVerificationSMS::dispatch($code); | SignupVerificationSMS::dispatch($code); | ||||
} else { | } else { | ||||
SignupVerificationEmail::dispatch($code); | SignupVerificationEmail::dispatch($code); | ||||
} | } | ||||
Show All 40 Lines | public function verify(Request $request) | ||||
$this->code = $code; | $this->code = $code; | ||||
$has_domain = $this->getPlan()->hasDomain(); | $has_domain = $this->getPlan()->hasDomain(); | ||||
// Return user name and email/phone/voucher from the codes database, | // Return user name and email/phone/voucher from the codes database, | ||||
// domains list for selection and "plan type" flag | // domains list for selection and "plan type" flag | ||||
return response()->json([ | return response()->json([ | ||||
'status' => 'success', | 'status' => 'success', | ||||
'email' => $code->data['email'], | 'email' => $code->email, | ||||
'first_name' => $code->data['first_name'], | 'first_name' => $code->first_name, | ||||
'last_name' => $code->data['last_name'], | 'last_name' => $code->last_name, | ||||
'voucher' => $code->data['voucher'], | 'voucher' => $code->voucher, | ||||
'is_domain' => $has_domain, | 'is_domain' => $has_domain, | ||||
'domains' => $has_domain ? [] : Domain::getPublicDomains(), | 'domains' => $has_domain ? [] : Domain::getPublicDomains(), | ||||
]); | ]); | ||||
} | } | ||||
/** | /** | ||||
* Finishes the signup process by creating the user account. | * Finishes the signup process by creating the user account. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | class SignupController extends Controller | ||||
* Returns plan for the signup process | * Returns plan for the signup process | ||||
* | * | ||||
* @returns \App\Plan Plan object selected for current signup process | * @returns \App\Plan Plan object selected for current signup process | ||||
*/ | */ | ||||
protected function getPlan() | protected function getPlan() | ||||
{ | { | ||||
if (!$this->plan) { | if (!$this->plan) { | ||||
// Get the plan if specified and exists... | // Get the plan if specified and exists... | ||||
if ($this->code && $this->code->data['plan']) { | if ($this->code && $this->code->plan) { | ||||
$plan = Plan::where('title', $this->code->data['plan'])->first(); | $plan = Plan::where('title', $this->code->plan)->first(); | ||||
} | } | ||||
// ...otherwise use the default plan | // ...otherwise use the default plan | ||||
if (empty($plan)) { | if (empty($plan)) { | ||||
// TODO: Get default plan title from config | // TODO: Get default plan title from config | ||||
$plan = Plan::where('title', 'individual')->first(); | $plan = Plan::where('title', 'individual')->first(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |