예제 #1
0
 public function create_user($userdata)
 {
     $password = \Arr::get($userdata, 'password', null);
     $email = \Arr::get($userdata, 'email', null);
     if (is_null($password) || is_null($email)) {
         Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email);
         throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
     }
     $user = Auth_Driver::get_core_user($email);
     $security = new Model_User_Security();
     //Generate a salt
     $security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random());
     $security->password = Hasher::instance()->hash($password, $security->salt);
     if (\Config::get('ethanol.activate_emails', false)) {
         $keyLength = \Config::get('ethanol.activation_key_length');
         $security->activation_hash = Random::instance()->random($keyLength);
         $user->activated = 0;
         //Send email
         \Package::load('email');
         //Build an array of data that can be passed to the email template
         $emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash)));
         $email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send();
     } else {
         $user->activated = 1;
         $security->activation_hash = '';
     }
     $user->security = $security;
     $user->save();
     $user->clean_security();
     return $user;
 }
예제 #2
0
파일: Google.php 프로젝트: inespons/ethanol
 public function get_form()
 {
     $client_id = \Config::get('ethanol.google.client_id');
     $client_secret = \Config::get('ethanol.google.client_secret');
     $redirect_uri = urlencode(parent::get_login_controller_path('google'));
     $scope = 'https://www.googleapis.com/auth/userinfo.email';
     $login_url = "https://accounts.google.com/o/oauth2/auth\n?scope={$scope}\n&redirect_uri={$redirect_uri}\n&response_type=code\n&client_id={$client_id}";
     return \View::forge('ethanol/driver/google_login')->set('loginUrl', $login_url)->render();
 }
예제 #3
0
 /**
  * Logs a user in and makes sure there's an assocated Ethanol user as well
  */
 public function validate_user($userdata)
 {
     //User wants to log in so make sure there's an Ethanol user as well
     if ($userdata['state'] != Session::instance()->get_instance()->get('ethanol.driver.facebook.csrf')) {
         Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, null);
         throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
     }
     //Remove the csrf token now that it has been validated
     Session::instance()->get_instance()->set('ethanol.driver.facebook.csrf', '');
     $app_id = \Config::get('ethanol.facebook.app_id');
     $app_secret = \Config::get('ethanol.facebook.app_secret');
     $code = \Arr::get($userdata, 'code');
     $redirect_url = urlencode(parent::get_login_controller_path('facebook'));
     //Get an access token from FB
     $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&redirect_uri=" . $redirect_url . "&client_secret=" . $app_secret . "&code=" . $code;
     $params = parent::get_access_token($token_url, 'facebook');
     //Now we have an access token lets get the email and finally create/check
     //the ethanol user.
     $graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token'];
     $facebookUser = json_decode(file_get_contents($graph_url));
     $email = $facebookUser->email;
     //Got a user so log in now
     return parent::perform_login($email, 'facebook');
 }
예제 #4
0
파일: ORM.php 프로젝트: nemmy/Ushahidi_Web
 /**
  * Complete the login for a user by incrementing the logins and setting
  * session data: user_id, username, roles
  *
  * @param   object   user model object
  * @return  void
  */
 protected function complete_login(User_Model $user)
 {
     // Update the number of logins
     $user->logins += 1;
     // Set the last login date
     $user->last_login = time();
     // Save the user
     $user->save();
     return parent::complete_login($user);
 }
예제 #5
0
 /**
  * Complete the login for a owner by incrementing the logins and setting
  * session data: owner_id, ownername, roles
  *
  * @param   object   owner model object
  * @return  void
  */
 protected function complete_login($owner)
 {
     // Update the number of logins
     $owner->logins += 1;
     // Set the last login date
     $owner->last_login = time();
     // Save the owner
     $owner->save();
     return parent::complete_login($owner);
 }
예제 #6
0
 /**
  * Constructor loads the user list into the class.
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     // Load user list
     $this->users = empty($config['users']) ? array() : $config['users'];
 }
예제 #7
0
파일: ORM.php 프로젝트: plusjade/plusjade
 /**
  * Complete the login for a user by incrementing the logins and setting
  * session data: user_id, username, roles
  *
  * @param   object   user model object
  * @return  void
  */
 protected function complete_login(Account_User_Model $user)
 {
     return parent::complete_login($user);
 }
예제 #8
0
파일: Tiki.php 프로젝트: swk/bluebox
 /**
  * Constructor loads the user list into the class.
  */
 public function __construct(array $config, $passwordOrig = '')
 {
     parent::__construct($config);
     include_once "Doctrine.php";
     $this->doctrine = new Auth_Doctrine_Driver($config);
     if (empty($passwordOrig) && !empty($_REQUEST['login']['password'])) {
         $passwordOrig = $_REQUEST['login']['password'];
     }
     $this->passwordOrig = $passwordOrig;
 }
예제 #9
0
파일: Doctrine.php 프로젝트: swk/bluebox
 /**
  * Constructor loads the user list into the class.
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
 }
예제 #10
0
파일: LDAP.php 프로젝트: nocash/KadLDAP
 public function __construct(array $config)
 {
     $this->ldap = KadLDAP::instance();
     parent::__construct($config);
 }