Files
thetool/Layout/default/UserProfile/Index.php
Spitzer_Daniel 28ca65fa6d UserToken Methoden static hinzugefügt
Bug bei Passwortlängencheck gefixt
JS Request URLs auf getUrl umgebaut
2FA Code wird bei eingabe nun üngiltig
2023-08-28 15:25:59 +02:00

202 lines
9.5 KiB
PHP

<?php
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<style>
.fa-exclamation-triangle {
font-size: 19px;
color: red;
}
.fa-new-code {
cursor: pointer;
color: #007bff;
font-size: 16px;
margin-left: 5px;
}
.fa-envelope, .fa-mobile-retro {
font-size: 25px;
vertical-align: sub;
margin-right: 5px;
}
</style>
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
</ol>
</div>
<h4 class="page-title">Benutzerprofil</h4>
</div>
</div>
</div>
<!-- end page title -->
<?php
if ($userprofile->twofactor == 0) {
$twoFactorsym = '<i class="fa fa-exclamation-triangle mr-1"></i>';
$twoFactorbtn = '<button class="btn btn-success mb-3 ">Aktivieren</button>';
$twoFactortype = '<div class="col-lg-2">
<select class="select2 form-control" name="twofactor" id="twofactor">
<option value="1">Email</option>
<option value="2">SMS</option>
</select></div>';
$twoFactorFormaction = "code2faaction";
} else if ($userprofile->twofactor == 1) {
$twoFactorsym = '<i class="fa-regular fa-circle-check mr-1"></i>';
$twoFactorbtn = '<button class="btn btn-success mb-3 ">Ändern zu SMS</button>';
$twoFactortype = '<label class="col-lg-2 col-form-label"><input type="hidden" name="twofactor" value="2"/><i class="fa-light fa-envelope"></i> Email</label>';
$twoFactorFormaction = "change2faaction";
} else if ($userprofile->twofactor == 2) {
$twoFactorsym = '<i class="fa-regular fa-circle-check mr-1"></i>';
$twoFactorbtn = '<button class="btn btn-success mb-3 ">Ändern zu Email</button>';
$twoFactortype = '<label class="col-lg-2 col-form-label"><input type="hidden" name="twofactor" value="1"/><i class="fa-light fa-mobile-retro"></i> Mobiltelefon (SMS)</label>';
$twoFactorFormaction = "change2faaction";
}
?>
<i class="bi bi-exclamation-triangle"></i>
<div class="row">
<div class="col-lg">
<div class="card">
<div class="card-body">
<h4 class=" mb-2">Allgemeine Daten</h4>
<div class="form-group row">
<div class="col-lg-2 font-weight-500">Name</div>
<div class="col-lg-10">
<?= $userprofile->name ?>
</div>
</div>
<div class="form-group row">
<div class="col-lg-2 font-weight-500">Email</div>
<div class="col-lg-10">
<?= $userprofile->email ?>
</div>
</div>
<div class="form-group row">
<div class="col-lg-2 font-weight-500">Mobiltelefon</div>
<div class="col-lg-10">
<?= $userprofile->mobile ?>
</div>
</div>
<div class="form-group row">
<div class="col-lg-10">
<a class="btn btn-primary mb-2"
href="<?= self::getUrl("UserProfile", "edit") ?>">Bearbeiten</a>
</div>
</div>
<div class="w-100 border-bottom"></div>
<h4 class=" mb-2 mt-3">Passwort ändern</h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("UserProfile", "changepwd") ?>">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="oldpwd">altes Passwort</label>
<div class="col-lg-2">
<input type="password" class="form-control" name="oldpwd" id="oldpwd"
value="">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="newpwd">neues Passwort</label>
<div class="col-lg-2">
<input type="password" class="form-control" name="newpwd" id="newpwd"
value="">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="checkpwd">Passwort bestätigen</label>
<div class="col-lg-2">
<input type="password" class="form-control" name="checkpwd" id="checkpwd"
value="">
</div>
</div>
<div class="form-group row">
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
<div class="w-100 border-bottom"></div>
<h4 class="form-group mb-2 mt-3">2FA</h4>
<?php if (!$verification || $verification == 0): ?>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("UserProfile", $twoFactorFormaction) ?>">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="twofactor"><?= $twoFactorsym ?>
Zwei-Faktor-Authentifizierung</label>
<?= $twoFactortype ?>
<div class="col-lg-7">
<?= $twoFactorbtn ?>
</div>
</div>
</form>
<?php elseif ($verification == 1 || $verification == 2) :
if ($verification == 1) {
$verificationType = "Email";
} elseif ($verification == 2) {
$verificationType = "SMS";
}
?>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("UserProfile", "activate2faaction") ?>">
<div class="row">
<div class="col-lg-2"></div>
<label class="col-lg-3 col-form-label"
style="vertical-align: top;font-size: 15px;color: #000;"> Code wurde
per <?php echo $verificationType; ?> verschickt (5 Minuten gültig)</label>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="code">Verifizierungscode: <i
data-codetype="<?= $verification ?>"
class="fa-solid fa-arrows-rotate fa-new-code" id="new-authcode"
title="Neuen Code anfordern."></i></label>
<div class="col-lg-2">
<input type="number" required min="0" max="99999" class="form-control" name="code"
id="code"
value="">
<input type="hidden" name="twofactor" value="<?php echo $verification; ?>"/>
</div>
<div class="col-lg-7">
<?= $twoFactorbtn ?>
<a href="/UserProfile">
<button type="button" class="btn btn-secondary mb-3">Abbrechen</button>
</a>
</div>
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [5];
$(document).ready(function () {
$("body").on("click", "#new-authcode", function (event) {
$.getJSON("<?= self::getUrl("UserProfile", "api", ['do' => 'sendcode', 'twofactor' => $verification]) ?>", {}).done(function (data) {
$("#new-authcode").hide(0).delay(5000).show(0);
}).fail(function (jqxhr, textStatus, error) {
window.location.href = "<?= self::getUrl("Dashboard") ?>";
});
});
})
;
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>