public function doSignUp(SignUpRequest $request) { $username = $request->get('username'); $email = $request->get('email'); $phone = $request->get('phone'); $password = $request->get('password'); $nickname = $request->has('nickname') ? $request->get('nickname') : ''; $verificationCodeForUsername = $request->get('verification_code_for_username'); $verificationCodeForPhone = $request->get('verification_code_for_phone'); $verificationCodeForEmail = $request->get('verification_code_for_email'); if ($username) { throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); } if ($email) { throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); } if ($phone) { throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); } $user = UserManager::signUp($username, $email, $phone, $password); $user->roles()->attach(System::getDefaultRole()); $user->save(); $userInfo = new UserInfo(); $userInfo->user()->associate($user); $userInfo->save(); return $this->buildResponse(trans('api.auth.sign_up.success'), $user); }
public function fire() { App::setLocale('en'); try { \DB::table('options')->get(); } catch (QueryException $exception) { $this->error('Run artisan migrate before app install.'); return; } if (System::isInstalled()) { $this->error('App is already installed.'); return; } $siteName = $this->ask('Site Name?'); $masterUsername = $this->ask('Master Username?'); $masterEmail = $this->ask('Master Email?'); $masterPassword = $this->secret('Master Password?'); $confirmPassword = $this->secret('Confirm Password?'); $validator = Validator::make(['username' => $masterUsername, 'email' => $masterEmail, 'password' => $masterPassword, 'password_confirmation' => $confirmPassword, 'verification_code_for_username' => '-', 'verification_code_for_email' => '-'], (new SignUpRequest())->rules()); if ($validator->fails()) { foreach ($validator->errors()->all() as $error) { $this->error($error); } return; } System::setSiteName($siteName); $masterRole = new App\Role(); $masterRole->name = 'Master'; $masterRole->save(); System::setMasterRoleId($masterRole->id); $adminRole = new App\Role(); $adminRole->name = 'Administrator'; $adminRole->save(); System::setAdministratorRoleId($adminRole->id); $editorRole = new App\Role(); $editorRole->name = 'Editor'; $editorRole->save(); System::setEditorRoleId($editorRole->id); $defaultRole = new App\Role(); $defaultRole->name = 'User'; $defaultRole->save(); System::setDefaultRoleId($defaultRole->id); $user = UserManager::signUp($masterUsername, $masterEmail, null, $masterPassword); $user->save(); $user->roles()->attach($masterRole); $user->roles()->attach($adminRole); $user->roles()->attach($editorRole); $user->roles()->attach($defaultRole); Option::setValueByKey('installed', true); $this->info('Install success!'); }