Esempio n. 1
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();
	}
Esempio n. 2
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();
 }