protected function startSessionAs($user, $level) { if (!is_null(S::user()) && S::user()->id() != $user->id() || S::has('uid') && S::i('uid') != $user->id()) { return false; } else { if (S::has('uid')) { return true; } } if ($level == AUTH_SUID) { S::set('auth', AUTH_PASSWD); } // Loads uid and hruid into the session for developement conveniance. $_SESSION = array_merge($_SESSION, array('uid' => $user->id(), 'hruid' => $user->hruid, 'token' => $user->token, 'user' => $user)); // Starts the session's logger, and sets up the permanent cookie. if (S::suid()) { S::logger()->log("suid_start", S::v('hruid') . ' by ' . S::suid('hruid')); } else { S::logger()->saveLastSession(); Cookie::set('uid', $user->id(), 300); if (S::i('auth_by_cookie') == $user->id() || Post::v('remember', 'false') == 'true') { $this->setAccessCookie(false, S::i('auth_by_cookie') != $user->id()); } else { $this->killAccessCookie(); // If login for an external website and not activating cookie, // mark that we want to disconnect once external auth checks // have been performed. if (Post::b('external_auth')) { S::set('external_auth_exit', true); } } } // Finalizes the session setup. $this->makePerms($user->perms, $user->is_admin); $this->securityChecks(); $this->setSkin(); $this->updateNbNotifs(); // Only check email redirection for 'internal' users. if ($user->checkPerms(PERMS_USER)) { check_redirect(); } // We should not have to use this private data anymore S::kill('auth_by_cookie'); return true; }
public function enable() { XDB::execute("UPDATE email_redirect_account\n SET flags = 'active'\n WHERE flags = 'disable' AND uid = {?}", $this->user->id()); foreach ($this->emails as &$mail) { if ($mail->disabled) { $mail->disabled = false; $mail->active = true; } check_redirect($this); } $this->update_imap(); }