Ejemplo n.º 1
0
 public function getIdentity($entity, $provider, $type)
 {
     if (!$entity->exists()) {
         return null;
     }
     return Identities::first(array('conditions' => array('user_id' => $entity->_id, 'prv_name' => $provider, 'type' => $type)));
 }
Ejemplo n.º 2
0
 public function index()
 {
     $user = $this->CURRENT_USER;
     $ids = Identities::all(array('conditions' => array('user_id' => $user->_id)));
     $identities = array();
     foreach ($ids as $id) {
         $identities[$id->type] = $id->to('array');
     }
     return compact('user', 'identities');
 }
Ejemplo n.º 3
0
 public static function __init()
 {
     parent::__init();
     self::applyFilter('save', function ($self, $params, $chain) {
         if (isset($params['data']['password'])) {
             $params['data']['prv_secret'] = Password::hash($params['data']['password']);
             unset($params['data']['password']);
         }
         if (isset($params['data']['prv_uid'])) {
             $params['data']['prv_uid'] = strtolower($params['data']['prv_uid']);
         }
         return $chain->next($self, $params, $chain);
     });
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
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);
    }
}