function bb_login($login, $password, $remember = false)
 {
     $user = bb_check_login($login, $password);
     if ($user && !is_wp_error($user)) {
         bb_set_auth_cookie($user->ID, $remember);
         do_action('bb_user_login', (int) $user->ID);
     }
     return $user;
 }
Beispiel #2
0
 /**
  * Checks the user credentials supplied in the request to make sure they are valid
  *
  * @since 1.0
  * @return integer|boolean The user id if the user is valid, otherwise false
  * @param string $user_login The users login
  * @param string $user_pass The users password in plain text
  * @param string $capability The capability to check (optional)
  * @param string $message The message to pass back in the error if the capability check fails (optional)
  */
 function authenticate($user_login, $user_pass, $capability = 'read', $message = false)
 {
     if (is_array($user_login)) {
         $auth_user_login = (string) $user_login[0];
         $switch_user_login = (string) $user_login[1];
     } else {
         $auth_user_login = (string) $user_login;
         $switch_user_login = false;
     }
     // Check the login
     $user = bb_check_login($auth_user_login, $user_pass);
     if (!$user || is_nxt_error($user)) {
         $this->error = new IXR_Error(403, __('Authentication failed.'));
         return false;
     }
     // Set the current user
     $user = bb_set_current_user($user->ID);
     // Make sure they are allowed to do this
     if (!bb_current_user_can($capability)) {
         if (!$message) {
             $message = __('You do not have permission to read this.');
         }
         $this->error = new IXR_Error(403, $message);
         return false;
     }
     // Switch the user if requested and allowed
     if ($switch_user_login && $this->allow_user_switching && bb_current_user_can('edit_users')) {
         $user = $this->switch_user($switch_user_login, $capability, $message);
     }
     return $user;
 }