Example #1
0
 /**
  * Finishes the administration setup.
  *
  * @param SetupRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function finish(SetupRequest $request)
 {
     $user = $this->user->newInstance();
     if ($this->dispatch(new Finish($request, $user))) {
         return view('admin.setup.complete');
     }
     flash()->error('Error!', 'There was an issue completing setup. Please try again.');
     return redirect()->route('admin.setup.begin');
 }
Example #2
0
 /**
  * Creates a new user.
  *
  * @param UserRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(UserRequest $request)
 {
     $this->authorize('admin.users.create');
     $user = $this->user->newInstance();
     if ($this->dispatch(new Store($request, $user))) {
         flash()->success('Success!', 'Successfully created user.');
         return redirect()->route('admin.users.index');
     }
     flash()->error('Error!', 'There was an issue creating a user. Please try again.');
     return redirect()->route('admin.users.create');
 }
Example #3
0
 /**
  * Creates a new user.
  *
  * @param User $model
  *
  * @return User|bool
  */
 public function handle(User $model)
 {
     $exists = $model->where('email', $this->email)->first();
     if (is_null($exists)) {
         $user = $model->newInstance();
         $user->email = $this->email;
         $user->name = $this->name;
         if ($user->hasSetMutator('password')) {
             // If the user model has a password set mutator, we'll assume
             // the developer is encrypting the passwords themselves.
             $user->password = $this->password;
         } else {
             // Otherwise we'll encrypt the password.
             $user->password = bcrypt($this->password);
         }
         $user->save();
         return $user;
     }
     return false;
 }
 /**
  * Finishes the administration setup.
  *
  * @param SetupRequest $request
  *
  * @return bool
  */
 public function finish(SetupRequest $request)
 {
     $user = $this->user->newInstance();
     return $this->dispatch(new Finish($request, $user));
 }
 /**
  * Creates a new user.
  *
  * @param UserRequest $request
  *
  * @return bool
  */
 public function store(UserRequest $request)
 {
     $this->authorize('admin.users.create');
     $user = $this->user->newInstance();
     return $this->dispatch(new Store($request, $user));
 }
 public function newInstance($attributes = [])
 {
     return $this->user->newInstance($attributes = []);
 }
Example #7
0
 /**
  * Obtain the user information from Provider.
  *
  * @param  string          $provider
  * @param  Socialite|SocialiteManager       $socialite
  * @param  User  $userModel
  *
  * @throws UnprocessableEntityException
  *
  * @return ApiResponse
  */
 public function handleProviderCallback($provider, Socialite $socialite, User $userModel)
 {
     $this->validateProvider($provider);
     $socialUser = $socialite->with($provider)->user();
     // Verify so we received an email address, if using oAuth credentials
     // with Twitter for instance, that isn't whitelisted, no email
     // address will be returned with the response.
     // See the notes in Spira API doc under Social Login for more info.
     if (!$socialUser->email) {
         // The app is connected with the service, but the 3rd party service
         // is not configured or allowed to return email addresses, so we
         // can't process the data further. Let's throw an exception.
         \Log::critical('Provider ' . $provider . ' does not return email.');
         throw new UnprocessableEntityException('User object has no email');
     }
     // Parse the social user to fit within Spira's user model
     $socialUser = ParserFactory::parse($socialUser, $provider);
     // Get or create the Spira user from the social login
     try {
         $user = $userModel->findByEmail($socialUser->email);
     } catch (ModelNotFoundException $e) {
         $user = $userModel->newInstance();
         $user->fill(array_merge($socialUser->toArray(), ['user_type' => 'guest']));
         $user->save();
     }
     $socialLogin = new SocialLogin(['provider' => $provider, 'token' => $socialUser->token]);
     $user->addSocialLogin($socialLogin);
     // Prepare response data
     $token = $this->jwtAuth->fromUser($user, ['method' => $provider]);
     $returnUrl = $socialite->with($provider)->getCachedReturnUrl() . '?jwtAuthToken=' . $token;
     $response = $this->getResponse();
     $response->redirect($returnUrl, 302);
     return $response;
 }