Merge pull request 'Set user related sessions for single user mode' (#82) from powerivq/tt-rss:language-session into master
Reviewed-on: https://dev.tt-rss.org/fox/tt-rss/pulls/82
This commit is contained in:
commit
d47b8c8494
|
@ -39,7 +39,7 @@
|
|||
header("Content-Type: text/json; charset=utf-8");
|
||||
|
||||
if (Config::get(Config::SINGLE_USER_MODE)) {
|
||||
UserHelper::authenticate( "admin", null);
|
||||
UserHelper::authenticate("admin", null);
|
||||
}
|
||||
|
||||
if (!empty($_SESSION["uid"])) {
|
||||
|
|
|
@ -394,10 +394,6 @@ class Handler_Public extends Handler {
|
|||
if (UserHelper::authenticate($login, $password)) {
|
||||
$_POST["password"] = "";
|
||||
|
||||
if (Config::get_schema_version() >= 120) {
|
||||
$_SESSION["language"] = get_pref(Prefs::USER_LANGUAGE, $_SESSION["uid"]);
|
||||
}
|
||||
|
||||
$_SESSION["ref_schema_version"] = Config::get_schema_version();
|
||||
$_SESSION["bw_limit"] = !!clean($_POST["bw_limit"] ?? false);
|
||||
$_SESSION["safe_mode"] = $safe_mode;
|
||||
|
|
|
@ -83,19 +83,15 @@ class UserHelper {
|
|||
$user = ORM::for_table('ttrss_users')->find_one($user_id);
|
||||
|
||||
if ($user && $user->access_level != self::ACCESS_LEVEL_DISABLED) {
|
||||
$_SESSION["uid"] = $user_id;
|
||||
self::set_session_for_user($user_id);
|
||||
$_SESSION["auth_module"] = $auth_module;
|
||||
$_SESSION["name"] = $user->login;
|
||||
$_SESSION["access_level"] = $user->access_level;
|
||||
$_SESSION["csrf_token"] = bin2hex(get_random_bytes(16));
|
||||
$_SESSION["ip_address"] = UserHelper::get_user_ip();
|
||||
$_SESSION["pwd_hash"] = $user->pwd_hash;
|
||||
|
||||
$user->last_login = Db::NOW();
|
||||
$user->save();
|
||||
|
||||
$_SESSION["last_login_update"] = time();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -108,8 +104,7 @@ class UserHelper {
|
|||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
$_SESSION["uid"] = 1;
|
||||
self::set_session_for_user(1);
|
||||
$_SESSION["name"] = "admin";
|
||||
$_SESSION["access_level"] = self::ACCESS_LEVEL_ADMIN;
|
||||
|
||||
|
@ -118,16 +113,23 @@ class UserHelper {
|
|||
|
||||
$_SESSION["auth_module"] = false;
|
||||
|
||||
if (empty($_SESSION["csrf_token"]))
|
||||
$_SESSION["csrf_token"] = bin2hex(get_random_bytes(16));
|
||||
|
||||
$_SESSION["ip_address"] = UserHelper::get_user_ip();
|
||||
$_SESSION["last_login_update"] = time();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static function set_session_for_user(int $owner_uid): void {
|
||||
$_SESSION["uid"] = $owner_uid;
|
||||
$_SESSION["last_login_update"] = time();
|
||||
$_SESSION["ip_address"] = UserHelper::get_user_ip();
|
||||
|
||||
if (empty($_SESSION["csrf_token"]))
|
||||
$_SESSION["csrf_token"] = bin2hex(get_random_bytes(16));
|
||||
|
||||
if (Config::get_schema_version() >= 120) {
|
||||
$_SESSION["language"] = get_pref(Prefs::USER_LANGUAGE, $owner_uid);
|
||||
}
|
||||
}
|
||||
|
||||
static function load_user_plugins(int $owner_uid, PluginHost $pluginhost = null): void {
|
||||
|
||||
if (!$pluginhost) $pluginhost = PluginHost::getInstance();
|
||||
|
|
Loading…
Reference in New Issue