refactoring login form, add logout to the tests

This commit is contained in:
marko
2024-11-17 10:00:40 +01:00
parent 3b31b112a7
commit 6fb6ea9983
4 changed files with 60 additions and 53 deletions

View File

@@ -2,7 +2,7 @@
/// @file common settings and includes for the participo api
/// - set locale to german
setlocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge");
/// - extend the include search path for
/// - extend the include search path for:
set_include_path(implode(
PATH_SEPARATOR,
[

View File

@@ -46,46 +46,49 @@ else {
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- includes of neccessary libs -->
<!-- includes of necessary libs -->
<?php readfile('./shared/imports.php'); ?>
<title>cwsvJudo Online Apps</title>
<meta name="description" content="Loginseite der Online-Apps der Judoka des CWSV">
<meta name="description" content="Login-Seite der Online-Apps der Judoka des CWSV">
</head>
<body class="container">
<h1>Loginseite der Online-Apps der Judoka des CWSV</h1>
<body>
<h1>Login-Seite der Online-Apps der Judoka des CWSV</h1>
<?php echo(htmlRetMessage(participo::getMessages())); ?>
<form action="./login.php" method="post">
<fieldset>
<legend>Benutzerdaten</legend>
<div>
<label for="username">Benutzername</label>
<div class="container">
<div class="row">
<div class="col s6 offset-s3 z-depth-1">
<h2 id="title">Benutzerdaten</h2>
<form id="loginForm" action="./login.php" method="post">
<div class="input-field">
<input id="username" type="text" name="f[username]" <?php echo isset($_POST['f']['username']) ? ' value="' . htmlspecialchars($_POST['f']['username']) . '"' : '' ?> />
<label for="username">Benutzername</label>
</div>
<div>
<label for="password">Kennnwort</label>
<div class="input-field">
<input id="password" type="password" name="f[password]" />
<label for="password">Kennwort</label>
</div>
<?php if (isset($_GET['returnToUrl'])) {
<?php # If a return url was given, add it as input to the form
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']) . '" />');
} ?>
}
?>
<input id="fragment" type="hidden" name="fragment" />
<!-- add the fragment to the post data-->
<!-- add the fragment (stuff behind the # in the url) to the post data -->
<script>
if(window.location.hash){
document.getElementById("fragment").value=window.location.hash;
}
</script>
</fieldset>
<fieldset>
<div>
<input type="submit" name="submit" value="Anmelden" />
</div>
</fieldset>
<!-- <p>
<input type="checkbox" id="remember"/>
<label for="remember" id="checkbox" >Remember me</label>
</p> -->
<input type="submit" name="submit" value="Anmelden" class="waves-effect waves-light btn" id="submitButton" />
<fieldset class="notice"><legend>Hinweise</legend>
<ul style="padding-left: inherit;">
<li style="list-style-type: circle;" >Logindaten sollten vom Übungsleiter vergeben worden sein.</li>
@@ -94,5 +97,9 @@ else {
</ul>
</fieldset>
</form>
</div>
</div>
</div>
</body>
</html>

View File

@@ -4,13 +4,13 @@
if (ini_get('session.use_cookies')) {
$params = session_get_cookie_params();
setcookie(
session_name(),
$name=session_name(),
'',
time() - 42000,
$params['path'],
$params['domain'],
$params['secure"'],
$params['httponly']
$expires=(time() - 42000),
$path=$params['path'] ?? "",
$domain=$params['domain'] ?? "",
$params['secure"'] ?? false,
$params['httponly'] ?? false
);
}
session_destroy();

View File

@@ -18,7 +18,7 @@ class TestParticipo(unittest.TestCase):
participo.login()
self.assertTrue(participo.check_login())
sections = ("events", "infoZettel", "attendance", "user")
sections = ("events", "infoZettel", "attendance", "user", "logout")
for section in sections:
with self.subTest(msg=f"- {section}"):
participo.load_section(section=section)