Ejemplo n.º 1
0
 /**
  * Send a email to a given user with a link to reset is password
  *
  * @author ZZK
  * @link   http://verecom.com
  *
  * @param UserInterface $user
  *
  * @return void
  */
 public function sendReset(UserInterface $user)
 {
     $view = Config::get('admin::views.email_password_forgot');
     $code = $user->getResetPasswordCode();
     Mail::queue($view, compact('code'), function ($message) use($user) {
         $message->to($user->email)->subject('Account Password Reset');
     });
 }
Ejemplo n.º 2
0
	/**
	 * Finds a throttling interface by the given user login.
	 *
	 * @param  string  $login
	 * @param  string  $ipAddress
	 * @return \Cartalyst\Sentry\Throttling\ThrottleInterface
	 */
	public function findByUserLogin($login, $ipAddress = null)
	{
		$user  = $this->userProvider->findByLogin($login);
		$model = $this->createModel();
		$query = $model->where('user_id', '=', ($userId = $user->getId()));

		if ($ipAddress)
		{
			$query->where(function($query) use ($ipAddress) {
				$query->where('ip_address', '=', $ipAddress);
				$query->orWhere('ip_address', '=', NULL);
			});
		}

		if ( ! $throttle = $query->first())
		{
			$throttle = $this->createModel();
			$throttle->user_id = $userId;
			if ($ipAddress) $throttle->ip_address = $ipAddress;
			$throttle->save();
		}

		return $throttle;
	}
Ejemplo n.º 3
0
 /**
  * Set the user associated with the social link.
  *
  * @param  Cartalyst\Sentry\Users\UserInterface  $user
  * @return void
  */
 public function setUser(UserInterface $user)
 {
     $this->user_id = $user->getId();
     $this->save();
 }
Ejemplo n.º 4
0
	/**
	 * Logs in the given user and sets properties
	 * in the session.
	 *
	 * @param  \Cartalyst\Sentry\Users\UserInterface  $user
	 * @param  bool  $remember
	 * @return void
	 * @throws \Cartalyst\Sentry\Users\UserNotActivatedException
	 */
	public function login(UserInterface $user, $remember = false)
	{
		if ( ! $user->isActivated())
		{
			$login = $user->getLogin();
			throw new UserNotActivatedException("Cannot login user [$login] as they are not activated.");
		}

		$this->user = $user;

		// Create an array of data to persist to the session and / or cookie
		$toPersist = array($user->getId(), $user->getPersistCode());

		// Set sessions
		$this->session->put($toPersist);

		if ($remember)
		{
			$this->cookie->forever($toPersist);
		}

		// The user model can attach any handlers
		// to the "recordLogin" event.
		$user->recordLogin();
	}
Ejemplo n.º 5
0
 /**
  * Logs in the given user and sets properties
  * in the session.
  *
  * @param  \Cartalyst\Sentry\Users\UserInterface  $user
  * @param  bool  $remember
  * @return void
  * @throws \Cartalyst\Sentry\Users\UserNotActivatedException
  */
 public function login(UserInterface $user, $remember = false)
 {
     if ($user->hasActivationRelaxed()) {
         $user->setActivationReminder(true);
         $c_date = new \DateTime(preg_replace('/\\s+(\\d{2})\\:(\\d{2})\\:(\\d{2})$/', '', $user->created_at));
         $t_date = new \DateTime();
         $difference = $c_date->diff($t_date);
         /* @all, this code works, but we'll keep it on the low for now....
         			
         			 if($difference->days >= 3){
         			    // @all, we'll stop relaxing the activation (i.e start enforcing activation) because the users time limit for activation is up!
         				$user->relax_activation = false;
         				$user->save();
         				
         			 }
         			 
         			*/
     } else {
         if (!$user->isActivated()) {
             $login = $user->getLogin();
             throw new UserNotActivatedException("Cannot login user [{$login}] as they are not activated.");
         } else {
             $user->setActivationReminder(false);
         }
     }
     $this->user = $user;
     // Create an array of data to persist to the session and / or cookie
     $toPersist = array($user->getId(), $user->getPersistCode());
     // Set sessions
     $this->session->put($toPersist);
     // TEMPORARY - Set Synergixe cookie -- Later we'll drive cross-domain access on native PHP sessions (instead of cookies) by creating a 'session_save_handler' for session based on the database!!
     setcookie('synergixe_sso', serialize($toPersist), time() + 24 * 3600, "/", ".synergixe.ng", FALSE, TRUE);
     if ($remember) {
         $this->cookie->forever($toPersist);
     }
     // The user model can attach any handlers
     // to the "recordLogin" event.
     $user->recordLogin();
 }
 /**
  * Fills a user with the given credentials, intelligently.
  *
  * @param  \Cartalyst\Sentry\Users\UserInterface  $user
  * @param  array  $credentials
  * @return void
  */
 protected function fill(UserInterface $user, array $credentials)
 {
     $loginNames = $user->getLoginNames();
     list($logins, $password, $credentials) = $this->parseCredentials($credentials, $loginNames);
     if (is_array($logins)) {
         foreach ($logins as $key => $value) {
             $user->{$key} = $value;
         }
     } else {
         $loginName = reset($loginNames);
         $user->{$loginName} = $logins;
     }
     foreach ($credentials as $key => $value) {
         $user->{$key} = $value;
     }
     if (isset($password)) {
         $password = $this->hasher->hash($password);
         $user->password = $password;
     }
 }
Ejemplo n.º 7
0
 /**
  * Finds a throttling interface by the given user login.
  *
  * @param  string  $login
  * @param  string  $ipAddress
  * @return \Cartalyst\Sentry\Throttling\ThrottleInterface
  */
 public function findByUserLogin($login, $ipAddress = null)
 {
     return $this->findByUser($this->userProvider->findByLogin($login), $ipAddress);
 }
Ejemplo n.º 8
0
 /**
  * Logs the given user into Sentry.
  *
  * @param  \Cartalyst\Sentry\Users\UserInterface  $user
  * @param  bool  $remember
  * @return void
  */
 protected function login(UserInterface $user, $remember = false)
 {
     $throttleProvider = $this->sentry->getThrottleProvider();
     // Now, we will check the throttling to ensure we are
     // not logging in a user which shouldn't be allowed.
     if ($throttleProvider->isEnabled()) {
         $throttle = $throttleProvider->findByUserId($user->getId(), $this->sentry->getIpAddress());
         $throttle->check();
     }
     $this->sentry->login($user, $remember);
 }
Ejemplo n.º 9
0
 /**
  * Add groups to a user
  *
  * @author ZZK
  * @link   http://verecom.com
  *
  * @param array                                 $groups
  * @param \Cartalyst\Sentry\Users\UserInterface $user
  */
 protected function syncGroups(array $groups, UserInterface $user)
 {
     $user->groups()->detach();
     $user->groups()->sync($groups);
 }
Ejemplo n.º 10
0
 /**
  * Prepare an email for account reset results
  *
  * @param User $user
  * @param string $reset_code
  * @throws PasswordResetCodeInvalidException
  * @throws PasswordResetFailedException
  */
 protected function prepareResetResultMailData($user, $reset_code)
 {
     $to = array('address' => $user->getAttribute('email'), 'name' => $user->getAttribute('first_name') . ' ' . $user->getAttribute('last_name'));
     $this->setTo($to);
     $this->setSubject($this->cmsName . ' | ' . $this->lang->get('larapress::email.Password Reset!'));
     $this->setData(array('new_password' => $this->attemptToReset($user, $reset_code)));
     $this->setView(array('text' => 'larapress::emails.new-password'));
 }