set() public static method

By default, before writing the data to the session, the set() method of the named configuration's adapter receives the data to be written, and has an opportunity to modify or reject it.
public static set ( string $name, array $data, array $options = [] ) : array
$name string The name of the adapter configuration to.
$data array The user data to be written to the session.
$options array Any additional session-writing options. These may override any options set by the default session configuration for `$name`.
return array Returns the array of data written to the session, or `false` if the adapter rejects the data.
Beispiel #1
0
 public function testManualSessionFail()
 {
     $this->assertFalse(Auth::check('test'));
     $user = array('id' => 13, 'user' => 'bob');
     $this->assertFalse(Auth::set('test', $user, array('fail' => true)));
     $this->assertFalse(Auth::check('test'));
 }
 public function login()
 {
     if ($this->request->data) {
         // Encrypt password which will be stored in Session
         $this->request->data['password'] = \lithium\util\String::hash($this->request->data['password']);
         $conditions = array('email' => $this->request->data['email'], 'password' => $this->request->data['password']);
         // Retrieve Author
         $author = Authors::find('first', compact('conditions'));
         // Add Author ID to Author authentification Session
         $this->request->data['id'] = $author->id;
         // Check Author existence from request data and create Author authentification Session
         if ($author && Auth::set('default', $this->request)) {
             return $this->redirect('Authors::dashboard');
         }
     }
 }
Beispiel #3
0
 public function login()
 {
     $result = Auth::check($this->request->adapter, $this->request);
     $redirectUrl = $this->request->env('HTTP_REFERER') ?: '/';
     if ($result) {
         # Convert array to identity object
         if ($this->request->adapter === 'password') {
             $result = Identities::find($result['_id']);
         }
         $session_data = array();
         $new_session = uniqid();
         if (isset($result['session']['id'])) {
             $session_data['id'] = (array) $result['session']['id']->data();
         } else {
             $session_data['id'] = array();
         }
         // Remember users for two weeks
         $session_data['expires'] = time() + \app\util\Config::get('session_length', 7) * 24 * 60 * 60;
         array_push($session_data['id'], $new_session);
         setcookie('session.id', $new_session, $session_data['expires'], '/', $_SERVER['HTTP_HOST']);
         $result->save(array('session' => $session_data));
         Auth::set('any', $result);
     } else {
         $addendum = '';
         // Adapter-specific error messages
         if ($this->request->adapter == 'phpbb') {
             if (Session::read('non_linked_phpbb_login')) {
                 Session::delete('non_linked_phpbb_login');
                 $addendum = 'You are logged into the forums, but there is no leagues account associated with with your forum account.';
             } else {
                 $addendum = 'Please ensure that you are logged into the <a href="http://www.afdc.com/forum/">forums</a>.';
             }
         } else {
             Logger::debug("Failed login for " . $this->request->data['email'] . " with password " . $this->request->data["password"]);
         }
         $error_message = 'Your login was unsuccessful. ';
         if (isset($addendum) and !empty($addendum)) {
             $error_message .= "<br />{$addendum}`<br />";
         }
         $error_message .= 'If you\'re having trouble, checkout the <a href="/help/login">login instructions</a>.';
         $this->flashMessage($error_message, array('alertType' => 'error'));
     }
     return $this->redirect($redirectUrl);
 }
 /**
  * Change email
  * @requestLogin
  */
 public function changeEmail()
 {
     $this->_rejectNotLogged();
     $user = $this->_user;
     unset($user['user_group']);
     $user = Users::first(array('conditions' => $user));
     if ($this->request->data) {
         if ($user->save(array('email' => $this->request->data['email']), array('events' => array('change_email')))) {
             Auth::set('default', array('email' => $user->email) + $this->_user);
             return $this->redirect('li3_usermanager.Users::index');
         }
     }
     return compact('user');
 }
 public function editAction()
 {
     $errors = array();
     $success = false;
     $user = null;
     if (!Auth::check('default')) {
         $errors['login'] = '******';
     } else {
         if (!$this->request->is('post')) {
             $errors['call'] = 'This action can only be called with post';
         } else {
             if (!($success = self::getUser($this->request->data['id'], $user))) {
                 $errors['user'] = '******'t exist';
             }
             if ($success && $this->request->data) {
                 if (!($success = $user->save($this->request->data))) {
                     $errors += $user->errors();
                 } else {
                     $currentSession = Auth::check('default');
                     if ($currentSession && $currentSession['id'] == $this->request->data['id']) {
                         $currentSession = $this->request->data + $currentSession;
                         Auth::set('default', $currentSession);
                     }
                 }
             }
         }
     }
     return compact('success', 'errors');
 }
Beispiel #6
0
 * alongside the normal registration data in the registration collection
 */
require __DIR__ . '/bootstrap/modules.php';
/**
 * This file contains your application's globalization rules, including inflections,
 * transliterations, localized validation, and how localized text should be loaded. Uncomment this
 * line if you plan to globalize your site.
 */
// require __DIR__ . '/bootstrap/g11n.php';
/**
 * This file contains configurations for handling different content types within the framework,
 * including converting data to and from different formats, and handling static media assets.
 */
require __DIR__ . '/bootstrap/media.php';
/**
 * This file configures console filters and settings, specifically output behavior and coloring.
 */
if (PHP_SAPI === 'cli') {
    require __DIR__ . '/bootstrap/console.php';
}
$paypal_config = \app\util\Config::get('paypal');
\app\util\Paypal::config($paypal_config['nvp']);
$mailchimp_config = \app\util\Config::get('mailchimp');
$MCAPI = new \app\extensions\helper\MCAPI($mailchimp_config['api-key']);
if (isset($_COOKIE['session_id'])) {
    $login_identity = Identities::first(array('conditions' => array('session.id' => $_COOKIE['session_id'], 'session.expires' => array('$gte' => time()))));
    if ($login_identity) {
        $login_identity->save(array('session.expires' => time() + \app\util\Config::get('session_length', 7) * 24 * 60 * 60));
        Auth::set('any', $login_identity);
    }
}