Skip to content

Commit

Permalink
login update user lang
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Apr 1, 2024
1 parent dea1677 commit d3edc3c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

class VerifyCsrfToken extends Middleware
{
const TG_WEBHOOK_PREFIX = "tg-webhook";
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
self::TG_WEBHOOK_PREFIX . "/*"
];
}
4 changes: 2 additions & 2 deletions include/constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.11');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-03-27');
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.12');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-04-01');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
Expand Down
20 changes: 13 additions & 7 deletions include/globalfunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,20 +470,26 @@ function arr_set(&$array, $key, $value)

function isHttps(): bool
{
$schema = nexus()->getRequestSchema();
return $schema == 'https';
if (isRunningInConsole()) {
$securityLogin = get_setting("security.securelogin");
if ($securityLogin != "no") {
return true;
}
return false;
}
return nexus()->getRequestSchema() == 'https';
}


function getSchemeAndHttpHost()
function getSchemeAndHttpHost(bool $fromConfig = false)
{
global $BASEURL;
if (isRunningInConsole()) {
return $BASEURL;
if (isRunningInConsole() || $fromConfig) {
$host = get_setting("basic.BASEURL");
} else {
$host = nexus()->getRequestHost();
}
$isHttps = isHttps();
$protocol = $isHttps ? 'https' : 'http';
$host = nexus()->getRequestHost();
return "$protocol://" . $host;
}

Expand Down
10 changes: 9 additions & 1 deletion public/takelogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function bark($text = "")
}
if ($iv == "yes")
check_code ($_POST['imagehash'], $_POST['imagestring'],'login.php',true);
$res = sql_query("SELECT id, passhash, secret, enabled, status, two_step_secret FROM users WHERE username = " . sqlesc($username));
$res = sql_query("SELECT id, passhash, secret, enabled, status, two_step_secret, lang FROM users WHERE username = " . sqlesc($username));
$row = mysql_fetch_array($res);

if (!$row)
Expand Down Expand Up @@ -83,6 +83,14 @@ function bark($text = "")

do_log($log);

//update user lang
$language = \App\Models\Language::query()->where("site_lang_folder", get_langfolder_cookie())->first();
if ($language && $language->id != $row["lang"]) {
do_log(sprintf("update user: %s lang: %s => %s", $row["id"], $row["lang"], $language->id));
\App\Models\User::query()->where("id", $row["id"])->update(["lang" => $language->id]);
clear_user_cache($row["id"]);
}

if (isset($_POST["logout"]) && $_POST["logout"] == "yes")
{
logincookie($row["id"], $passh,1,900,$securelogin_indentity_cookie, $ssl, $trackerssl);
Expand Down

0 comments on commit d3edc3c

Please sign in to comment.