redirecting login

This commit is contained in:
marko
2022-06-06 12:55:17 +02:00
parent 706b722b12
commit 3e3fb6d953
12 changed files with 304 additions and 144 deletions

View File

@@ -6,9 +6,17 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once("./local/dbConf.php");
// Check, if the login is already set. If so move to the main page.
require_once($config['basePath']."/config/cwsvJudo.config.php");
dbConnector::connect(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
// Check, if the login is already set. If so move to the main page
if (isset($_SESSION['login'])) {
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php');
header("Location: http://" . ($_POST['returnToUrl'] ?? "."), TRUE, 301);
}
// Otherwise check credentials if given.
else{
@@ -17,12 +25,14 @@ else{
empty($_POST['f']['username']) ||
empty($_POST['f']['password'])
) {
$message['error'] = 'Es wurden nicht alle Felder ausgefüllt.';
$message = ['error' => "Es wurden nicht alle Felder ausgefüllt."];
} else {
$message = checkCredentials($_POST['f']['username'], $_POST['f']['password'], $db_server, $db_user, $db_password, $db_name);
if( !isset($message['error']) )
$message['notice'] = "OnlineApps - cwsvJudo";
if( participo::checkCredentials( $_POST['f']['username'], $_POST['f']['password']) ){
$returnToUrl = $_POST['returnToUrl'] ?? ".";
participo::addMessage('success', "<div><a href=\"".$returnToUrl."\">weiter zum Inhalt</a>.</div>");
participo::addMessage('notice', "OnlineApps - cwsvJudo");
header("Location: " . $returnToUrl );
}
}
}
}
@@ -42,18 +52,20 @@ else{
</head>
<body class="container">
<h1>Loginseite der Online-Apps der Judoka des CWSV</h1>
<?php echo(htmlRetMessage($message));?>
<?php echo(htmlRetMessage(participo::getMessages()));?>
<form action="./login.php" method="post">
<fieldset>
<legend>Benutzerdaten</legend>
<div>
<label for="username">Benutzername</label>
<input id="username"type="text" name="f[username]" <?php echo isset($_POST['f']['username']) ? ' value="' . htmlspecialchars($_POST['f']['username']) . '"' : '' ?> />
<input id="username" type="text" name="f[username]" <?php echo isset($_POST['f']['username']) ? ' value="' . htmlspecialchars($_POST['f']['username']) . '"' : '' ?> />
</div>
<div>
<label for="password">Kennnwort</label>
<input id="password" type="password" name="f[password]" />
</div>
<?php if( isset( $_GET['returnToUrl']) ) echo("<input type=\"hidden\" name=\"returnToUrl\" value=\"".htmlspecialchars( $_GET['returnToUrl'])."\" />"); ?>
<?php if( isset($_POST['returnToUrl']) ) echo("<input type=\"hidden\" name=\"returnToUrl\" value=\"".htmlspecialchars($_POST['returnToUrl'])."\" />"); ?>
</fieldset>
<fieldset>
<div>