Exemplo n.º 1
0
 /**
  * This function is checking if the email address is already associated with any user.
  * @param $attribute
  * @param $value
  * @param $parameters
  * @return bool
  */
 public function validateCheckemailexist($attribute, $value, $parameters)
 {
     $SentryUser = new \SentryUser();
     if ($SentryUser->checkIfUserExist($value)) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Get all the user groups that a user lies in
  * @param SentryUser $user The user
  * @param  string $value Value
  * @param  key $key Key
  * @return array
  */
 public function getUserGroups($user, $value = null, $key = null)
 {
     if (!$value) {
         // If no value is passed return Sentry Object
         return $user->getGroups();
     }
     $groups = array();
     foreach ($user->getGroups() as $group) {
         if ($key) {
             $groups[$group->{$key}] = $group->{$value};
         } else {
             $groups[] = $group->{$value};
         }
     }
     return $groups;
 }
Exemplo n.º 3
0
 /**
  * Handling the OAuth login
  */
 public function handleOAuthLogin()
 {
     // get data from input
     $code = Input::get('code');
     // get google service
     $googleService = OAuth::consumer('Google');
     // check if code is valid
     // if code is provided get user data and sign in
     if (!empty($code)) {
         // This was a callback request from google, get the token
         $token = $googleService->requestAccessToken($code);
         // Send a request with it
         $result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
         $SentryUser = new SentryUser();
         // checking if the email domain is allowed
         if ($SentryUser->validateOAuthAllowedDomains($result['email'])) {
             $SentryUser->handleOAuthLogin($result);
             return Redirect::to($this->dashboard);
         } else {
             SentryHelper::dsm('This domain is not allowed on this site.', 'warning');
         }
     } else {
         // get googleService authorization
         $url = $googleService->getAuthorizationUri();
         // return to google login url
         return Redirect::to((string) $url);
     }
 }
Exemplo n.º 4
0
 public function onUserProfileChange($user)
 {
     $SentryUser = new SentryUser();
     $SentryUser->setUserSession($user->id);
 }