mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
move Ajax functions
This commit is contained in:
parent
1067559f41
commit
b34906976b
@ -152,79 +152,6 @@ class UserAuthenticator
|
||||
$this->events->dispatch(new UserWasLoggedIn($user));
|
||||
}
|
||||
|
||||
public function registerAjax(UserRepositoryInterface $users, Request $request)
|
||||
{
|
||||
$required_field = ['first_name', 'last_name', 'email', 'subdomain'];
|
||||
|
||||
foreach ($required_field as $field) {
|
||||
if (!isset($request->$field) or $request->$field == "") {
|
||||
return $this->responseJSON('error', $field . ' field is required!');
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
$siteModel = new SiteModel();
|
||||
$userPlan = new UserModel();
|
||||
$all = $request->all();
|
||||
|
||||
$email = explode('@', $all['email']);
|
||||
$all['display_name'] = $all['first_name'] . " " . $all['last_name'];
|
||||
$all['username'] = array_first($email);
|
||||
$all['username'] = preg_replace("/[^a-zA-Z0-9]/", "", $all['username']);
|
||||
$all['activated'] = 1; //Activated User
|
||||
$all['str_id'] = str_random(24); //User random key
|
||||
$planParams['plan'] = 24;
|
||||
|
||||
//find plan id for request
|
||||
if (isset($all['plan_id'])) {
|
||||
$planParams['plan'] = $all['plan_id'];
|
||||
unset($all['plan_id']);//Demo Plan id
|
||||
}
|
||||
|
||||
//find subdomain in allready exit
|
||||
$isSubdomain = $siteModel->getSitesBySubdomain($all['subdomain']);
|
||||
if ($this->advModel->is_enabled('cloudsite') and !is_null($isSubdomain)) {
|
||||
return $this->responseJSON('error', 'This subdomain is already exists!');
|
||||
}
|
||||
|
||||
|
||||
if (User::withTrashed()->where('email', $all['email'])->first() or User::withTrashed()->where('username', $all['username'])->first()) {
|
||||
return $this->responseJSON('error', 'This Username or Email Registered!');
|
||||
|
||||
}
|
||||
|
||||
//create random password
|
||||
$opassword = str_random(8);
|
||||
|
||||
$user_params = $all;
|
||||
unset($user_params['subdomain']);
|
||||
|
||||
//create user
|
||||
$user = User::query()->create($user_params);
|
||||
$user->setAttribute('password', $opassword);
|
||||
$users->save($user);
|
||||
$all['password'] = $opassword; //Register Password Original
|
||||
|
||||
$all['user'] = $user;
|
||||
|
||||
$planParams['user'] = $user->id; //Register User id
|
||||
$planParams['name'] = $all['subdomain']; //Subscription Saved Name
|
||||
|
||||
if ($this->advModel->is_enabled('cloudsite')) {
|
||||
$plan = $userPlan->addPlanAjaxUser($planParams);
|
||||
$siteModel->createSite($all['subdomain'], $user->id, $opassword, $plan->id); //Create Site
|
||||
//$this->events->dispatch(new CreateSite($all, $this->settings));
|
||||
}
|
||||
|
||||
return $this->responseJSON('success', 'Thank you for Registering!');
|
||||
|
||||
}
|
||||
|
||||
public function responseJSON($type, $message)
|
||||
{
|
||||
return response()->json(['status' => $type, 'message' => $message]);
|
||||
}
|
||||
|
||||
public function phoneValidation(Request $request, UserRepositoryInterface $userRepository)
|
||||
{
|
||||
$phoneNum = str_replace(' ', '', $request->phoneNumber);
|
||||
|
||||
@ -103,14 +103,6 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
'as' => 'profile::profile',
|
||||
'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@home'
|
||||
],
|
||||
|
||||
/* Register */
|
||||
'register/ajax' => [
|
||||
'uses' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@registerAjax',
|
||||
'middleware' => [
|
||||
\Barryvdh\Cors\HandleCors::class,
|
||||
]
|
||||
],
|
||||
'ajax/phone-validation' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@phoneValidation',
|
||||
|
||||
/* Login */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user