Example #1
0
 public function handleOAuthCallback()
 {
     /** @var Provider $driver */
     $driver = $this->getDriver();
     /** @var User $user */
     $user = $driver->user();
     $dfUser = $this->createShadowOAuthUser($user);
     $dfUser->last_login_date = Carbon::now()->toDateTimeString();
     $dfUser->confirm_code = null;
     $dfUser->save();
     Session::setUserInfoWithJWT($dfUser);
     return Session::getPublicInfo();
 }
 /**
  * Send a copy of each incoming request out to the cluster logging system
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     try {
         try {
             $_session = Session::getPublicInfo();
         } catch (\Exception $_ex) {
             $_session = Session::all();
         }
         //  Register the auditing service
         app()->register(AuditServiceProvider::class);
         //  We use provider's service() method because Facades aren't loaded yet
         AuditServiceProvider::service()->logRequest($request, $_session);
     } catch (\Exception $_ex) {
         //  Completely ignored...
         /** @noinspection PhpUndefinedMethodInspection */
         Log::error('Exception during auditing: ' . $_ex->getMessage());
     }
     return $next($request);
 }
Example #3
0
 /**
  * Performs login.
  *
  * @param array $credentials
  * @param bool  $remember
  *
  * @return array
  * @throws BadRequestException
  * @throws NotFoundException
  * @throws UnauthorizedException
  * @throws \Exception
  */
 protected function handleLogin(array $credentials = [], $remember = false)
 {
     $email = ArrayUtils::get($credentials, 'email');
     if (empty($email)) {
         throw new BadRequestException('Login request is missing required email.');
     }
     $password = ArrayUtils::get($credentials, 'password');
     if (empty($password)) {
         throw new BadRequestException('Login request is missing required password.');
     }
     $credentials['is_active'] = 1;
     // if user management not available then only system admins can login.
     if (!class_exists('\\DreamFactory\\Core\\User\\Resources\\System\\User')) {
         $credentials['is_sys_admin'] = 1;
     }
     if (Session::authenticate($credentials, $remember, true, static::getAppId())) {
         return Session::getPublicInfo();
     } else {
         throw new UnauthorizedException('Invalid credentials supplied.');
     }
 }
Example #4
0
 /**
  * Handles login using this service.
  *
  * @param array $credential
  * @param bool  $remember
  *
  * @return array
  * @throws \DreamFactory\Core\Exceptions\UnauthorizedException
  */
 public function handleLogin(array $credential, $remember = false)
 {
     $username = ArrayUtils::get($credential, 'username');
     $password = ArrayUtils::get($credential, 'password');
     $auth = $this->driver->authenticate($username, $password);
     if ($auth) {
         $ldapUser = $this->driver->getUser();
         $user = $this->createShadowADLdapUser($ldapUser);
         $user->last_login_date = Carbon::now()->toDateTimeString();
         $user->confirm_code = null;
         $user->save();
         Session::setUserInfoWithJWT($user, $remember);
         return Session::getPublicInfo();
     } else {
         throw new UnauthorizedException('Invalid username and password provided.');
     }
 }