Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve login for translations #1000

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tasmoadmin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ function getTitle(string $page, ?string $action = null): string
$context->fromRequest($request);
$matcher = new UrlMatcher($routes, $context);

$authByPassedPages = ['login', 'change_language'];

try {
extract($matcher->match($request->getPathInfo()), EXTR_SKIP);
$page = $_route;

if( !$loggedin && $page !== 'login' ) {
if( !$loggedin && !in_array($page, $authByPassedPages)) {
header( "Location: "._BASEURL_."login" );
exit();
}
Expand Down
2 changes: 1 addition & 1 deletion tasmoadmin/pages/change_language.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$_SESSION[ 'lang' ] = $new_lang;
$_SESSION['lang'] = $new_lang;
$redirect = $_GET['current'] ?? _BASEURL_;
header("Location: {$redirect}");
exit();
14 changes: 7 additions & 7 deletions tasmoadmin/pages/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use TasmoAdmin\Helper\LoginHelper;

$register = FALSE;
$msg = FALSE;
$register = false;
$msg = false;
$user = $Config->read("username");
$password = $Config->read("password");
$title = __("LOGIN", "PAGE_TITLES");
Expand All @@ -15,7 +15,7 @@

$loginHelper = new LoginHelper($Config);

if (isset($_POST) && !empty($_POST)) {
if (!empty($_POST)) {
$home = $Config->read("homepage");
if (isset($_REQUEST["register"]) && ($user === "" || $password === "")) {
$loginHelper->register($_REQUEST["username"], $_REQUEST["password"]);
Expand All @@ -34,8 +34,8 @@
}
}

if (empty($user) || empty($password) ) {
$register = TRUE;
if (empty($user) || empty($password)) {
$register = true;
}

?>
Expand Down Expand Up @@ -65,7 +65,7 @@
<div class="card-body">
<form class="form" name='loginform' method='POST'>
<div class="form-group col">
<label for="username">Username</label>
<label for="username"><?php echo __("LOGIN_USERNAME_PLACEHOLDER", "LOGIN"); ?></label>
<input type="text"
autofocus="autofocus"
class="form-control form-control-lg rounded-0"
Expand All @@ -78,7 +78,7 @@ class="form-control form-control-lg rounded-0"

</div>
<div class="form-group col">
<label>Password</label>
<label><?php echo __("LOGIN_PASSWORD_PLACEHOLDER", "LOGIN"); ?></label>
<input type="password"
class="form-control form-control-lg rounded-0"
id="password"
Expand Down
Loading