Exemplo n.º 1
0
 /**
  * Registers and authenticates a user by the specified credentials.
  *
  * @param array $credentials
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 private function registerAndAuthenticateUser(array $credentials)
 {
     $model = Sentinel::createModel();
     // See if the LDAP user already has an account first
     $user = $model->where('email', $credentials['email'])->first();
     if ($user) {
         // Update the user
         Sentinel::update($user, $credentials);
         // Log them in
         Sentinel::login($user);
         $message = 'Successfully logged in.';
         return redirect()->intended('/')->withSuccess($message);
     } else {
         $user = Sentinel::registerAndActivate($credentials);
         if ($user) {
             $user->username = $credentials['username'];
             $user->save();
             Sentinel::login($user);
             $message = 'Successfully logged in.';
             return redirect()->intended('/')->withSuccess($message);
         }
     }
     $message = 'There was an issue creating your active directory account. Please try again.';
     return redirect()->route('maintenance.login.index')->withErrors($message);
 }
Exemplo n.º 2
0
 public function deletedBy()
 {
     return Sentinel::createModel()->find($this->deleted_by);
 }