Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public function getIsDefaultAttribute()
 {
     $defaultRoleId = System::getDefaultRole()->id;
     foreach ($this->roles as $role) {
         if ($role->id == $defaultRoleId) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public function doSaveSetting(Request $request)
 {
     if ($request->has('site_name')) {
         System::setSiteName($request->get('site_name'));
     }
     if ($request->has('version')) {
         System::setVersion($request->get('version'));
     }
     if ($request->has('powered_name')) {
         System::setPoweredName($request->get('powered_name'));
     }
     return $this->buildResponse(trans('api.system.save-setting.success'));
 }
Exemplo n.º 4
0
 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!');
 }
Exemplo n.º 5
0
 public function handle(Request $request, Closure $next)
 {
     foreach ($this->except as $except) {
         if ($request->is($except)) {
             return $next($request);
         }
     }
     if (!System::isInstalled()) {
         throw new SystemException(SystemException::SystemNotInstall);
     }
     View::share('htmlTitle', System::getSiteName());
     View::share('siteName', System::getSiteName());
     return $next($request);
 }