Beispiel #1
0
 function logout()
 {
     common_set_user(null);
     common_real_login(false);
     // not logged in
     common_forgetme();
     // don't log back in!
 }
Beispiel #2
0
 /**
  * Class handler.
  * 
  * @param array $args array of arguments
  *
  * @return nothing
  */
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         $this->clientError(_('Not logged in.'));
     } else {
         common_set_user(null);
         common_real_login(false);
         // not logged in
         common_forgetme();
         // don't log back in!
         common_redirect(common_local_url('public'));
     }
 }
Beispiel #3
0
function common_remembered_user()
{
    $user = null;
    $packed = isset($_COOKIE[REMEMBERME]) ? $_COOKIE[REMEMBERME] : null;
    if (!$packed) {
        return null;
    }
    list($id, $code) = explode(':', $packed);
    if (!$id || !$code) {
        common_log(LOG_WARNING, 'Malformed rememberme cookie: ' . $packed);
        common_forgetme();
        return null;
    }
    $rm = Remember_me::staticGet($code);
    if (!$rm) {
        common_log(LOG_WARNING, 'No such remember code: ' . $code);
        common_forgetme();
        return null;
    }
    if ($rm->user_id != $id) {
        common_log(LOG_WARNING, 'Rememberme code for wrong user: '******' != ' . $id);
        common_forgetme();
        return null;
    }
    $user = User::staticGet($rm->user_id);
    if (!$user) {
        common_log(LOG_WARNING, 'No such user for rememberme: ' . $rm->user_id);
        common_forgetme();
        return null;
    }
    // successful!
    $result = $rm->delete();
    if (!$result) {
        common_log_db_error($rm, 'DELETE', __FILE__);
        common_log(LOG_WARNING, 'Could not delete rememberme: ' . $code);
        common_forgetme();
        return null;
    }
    common_log(LOG_INFO, 'logging in ' . $user->nickname . ' using rememberme code ' . $rm->code);
    common_set_user($user);
    common_real_login(false);
    // We issue a new cookie, so they can log in
    // automatically again after this session
    common_rememberme($user);
    return $user;
}
 /**
  * Delete the current user's account
  *
  * Checks for the "I am sure." string to make sure the user really
  * wants to delete their account.
  *
  * Then, marks the account as deleted and begins the deletion process
  * (actually done by a back-end handler).
  *
  * If successful it logs the user out, and shows a brief completion message.
  *
  * @return void
  */
 function deleteAccount()
 {
     $this->checkSessionToken();
     // !!! If this string is changed, it also needs to be changed in DeleteAccountForm::formData()
     // TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
     $iamsure = _('I am sure.');
     if ($this->trimmed('iamsure') != $iamsure) {
         // TRANS: Notification for user about the text that must be input to be able to delete a user account.
         // TRANS: %s is the text that needs to be input.
         $this->_error = sprintf(_('You must write "%s" exactly in the box.'), $iamsure);
         $this->showPage();
         return;
     }
     $cur = common_current_user();
     // Mark the account as deleted and shove low-level deletion tasks
     // to background queues. Removing a lot of posts can take a while...
     if (!$cur->hasRole(Profile_role::DELETED)) {
         $cur->grantRole(Profile_role::DELETED);
     }
     $qm = QueueManager::get();
     $qm->enqueue($cur, 'deluser');
     // The user is really-truly logged out
     common_set_user(null);
     common_real_login(false);
     // not logged in
     common_forgetme();
     // don't log back in!
     $this->_complete = true;
     $this->showPage();
 }
 function logoutWeb()
 {
     if (Event::handle('StartLogout', array($this))) {
         common_set_user(null);
         common_real_login(false);
         // not logged in
         common_forgetme();
         // don't log back in!
     }
     Event::handle('EndLogout', array($this));
 }