Files
thetool/Layout/default/UserProfile/Form.php
Spitzer_Daniel f95d0b0074 2FA/Remember Me Implementierung
Userprofile Implementierung

Datatables Padding Anpassungen

Usercontroller und User um Mobile erweitert
2023-08-17 09:42:18 +02:00

161 lines
7.8 KiB
PHP

<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<!-- start page title -->
<style>
.fa-new-code {
cursor: pointer;
color: #007bff;
font-size: 16px;
margin-left: 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>
<li class="breadcrumb-item"><a
href="<?= self::getUrl("UserProfile") ?>">Benutzerprofil</a></li>
<li class="breadcrumb-item active">bearbeiten</li>
</ol>
</div>
<h4 class="page-title">Benutzerprofil</h4>
</div>
</div>
</div>
<!-- end page title -->
<?php
$twofa = $userprofile->twofactor;
if ($twofa == 0) {
$formAction = self::getUrl("UserProfile", 'save');
} elseif ($twofa == 1) {
$formAction = self::getUrl("UserProfile", 'save');
} elseif ($twofa == 2) {
$formAction = self::getUrl("UserProfile", 'save');
}
?>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2">Allgemeine Daten</h4>
<form class="form-horizontal" method="post"
action="<?= $formAction ?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?= $devicetypes->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name *</label>
<div class="col-lg-3">
<input type="text" class="form-control input-control" name="name" id="name"
value="<?= $userprofile->name ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="email">Email *</label>
<div class="col-lg-3">
<input type="text" class="form-control input-control" name="email" id="email"
required="required"
value="<?= $userprofile->email ?>" <?php if ($twofa == 1) : ?> disabled="disabled" <?php endif; ?> />
</div>
<?php if ($twofa == 1) : ?>
<div class="col-lg-4 col-form-label">
<span class="info-span alert alert-info"> Um die Email Adresse zu ändern bitte 2FA auf SMS umschalten.</span>
</div>
<?php endif; ?>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="olt">Mobiltelefon</label>
<div class="col-lg-3">
<input placeholder="+4366411223344" type="text" class="form-control input-control"
name="mobile" id="mobile"
value="<?= $userprofile->mobile ?>" <?php if ($twofa == 2) : ?> disabled="disabled" <?php endif; ?>/>
</div>
<?php if ($twofa == 2) : ?>
<div class="col-lg-4 col-form-label">
<span class="info-span alert alert-info"> Um die Mobilnummer zu ändern bitte 2FA auf Email umschalten.</span>
</div>
<?php endif; ?>
</div>
<div id="verification2fa" class="form-group row" style="display:none">
<label class="col-lg-2 col-form-label" for="olt">Verifizierungscode<i
data-codetype="<?= $twofa ?>"
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" min="0" max="99999" class="form-control"
name="code" id="code"/>
</div>
<label class="col-lg-4 col-form-label" for="olt">Verifizierungscode wurde versendet
(5 Minuten gültig)</label>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button id="submit" type="submit" data-codetype="<?= $twofa ?>"
class="btn btn-primary">Speichern
</button>
<a href="/UserProfile">
<button type="button" class="btn btn-secondary">Abbrechen</button>
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
var verficationtype;
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/UserProfile/api?do=checkverfication", {}).done(function (data) {
verficationtype = data.data.verficationtype;
});
$('form').submit(function (e) {
var me = this;
if ($('#verification2fa').is(":hidden")) {
if (verficationtype > 0) {
e.preventDefault();
$('.input-control').attr('readonly', true);
$('#verification2fa').show();
$('#code').attr("required", true);
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/UserProfile/api?do=sendcode&twofactor=" + verficationtype, {}).done(function (data) {
}).fail(function (jqxhr, textStatus, error) {
window.location.href = "/Dashboard";
});
} else {
}
}
});
$("body").on("click", "#new-authcode", function (event) {
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/UserProfile/api?do=sendcode&twofactor=" + $('#new-authcode').data('codetype'), {}).done(function (data) {
$("#new-authcode").hide(0).delay(5000).show(0);
}).fail(function (jqxhr, textStatus, error) {
window.location.href = "/Dashboard";
});
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>