UserToken Methoden static hinzugefügt
Bug bei Passwortlängencheck gefixt JS Request URLs auf getUrl umgebaut 2FA Code wird bei eingabe nun üngiltig
This commit is contained in:
@@ -78,7 +78,8 @@ if ($twofa == 0) {
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="olt">Mobiltelefon</label>
|
<label class="col-lg-2 col-form-label" for="olt">Mobiltelefon</label>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<input placeholder="+4366411223344" type="text" class="form-control input-control"
|
<input placeholder="+4366411223344" type="text"
|
||||||
|
class="form-control input-control"
|
||||||
name="mobile" id="mobile"
|
name="mobile" id="mobile"
|
||||||
value="<?= $userprofile->mobile ?>" <?php if ($twofa == 2) : ?> disabled="disabled" <?php endif; ?>/>
|
value="<?= $userprofile->mobile ?>" <?php if ($twofa == 2) : ?> disabled="disabled" <?php endif; ?>/>
|
||||||
</div>
|
</div>
|
||||||
@@ -125,10 +126,7 @@ if ($twofa == 0) {
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var verficationtype;
|
var verficationtype = <?= $twofa ?>;
|
||||||
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/UserProfile/api?do=checkverfication", {}).done(function (data) {
|
|
||||||
verficationtype = data.data.verficationtype;
|
|
||||||
});
|
|
||||||
$('form').submit(function (e) {
|
$('form').submit(function (e) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if ($('#verification2fa').is(":hidden")) {
|
if ($('#verification2fa').is(":hidden")) {
|
||||||
@@ -138,18 +136,15 @@ if ($twofa == 0) {
|
|||||||
$('#verification2fa').show();
|
$('#verification2fa').show();
|
||||||
$('#code').attr("required", true);
|
$('#code').attr("required", true);
|
||||||
|
|
||||||
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/UserProfile/api?do=sendcode&twofactor=" + verficationtype, {}).done(function (data) {
|
$.getJSON("<?= self::getUrl("UserProfile", "api", ['do' => 'sendcode', 'twofactor' => $twofa]) ?>", {}).done(function (data) {
|
||||||
}).fail(function (jqxhr, textStatus, error) {
|
}).fail(function (jqxhr, textStatus, error) {
|
||||||
window.location.href = "/Dashboard";
|
window.location.href = "/Dashboard";
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("body").on("click", "#new-authcode", function (event) {
|
$("body").on("click", "#new-authcode", function (event) {
|
||||||
|
$.getJSON("<?= self::getUrl("UserProfile", "api", ['do' => 'sendcode', 'twofactor' => $twofa]) ?>", {}).done(function (data) {
|
||||||
$.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);
|
$("#new-authcode").hide(0).delay(5000).show(0);
|
||||||
}).fail(function (jqxhr, textStatus, error) {
|
}).fail(function (jqxhr, textStatus, error) {
|
||||||
window.location.href = "/Dashboard";
|
window.location.href = "/Dashboard";
|
||||||
|
|||||||
@@ -188,13 +188,14 @@ if ($userprofile->twofactor == 0) {
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("body").on("click", "#new-authcode", function (event) {
|
$("body").on("click", "#new-authcode", function (event) {
|
||||||
|
|
||||||
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/UserProfile/api?do=sendcode&twofactor=" + $('#new-authcode').data('codetype'), {}).done(function (data) {
|
$.getJSON("<?= self::getUrl("UserProfile", "api", ['do' => 'sendcode', 'twofactor' => $verification]) ?>", {}).done(function (data) {
|
||||||
$("#new-authcode").hide(0).delay(5000).show(0);
|
$("#new-authcode").hide(0).delay(5000).show(0);
|
||||||
}).fail(function (jqxhr, textStatus, error) {
|
}).fail(function (jqxhr, textStatus, error) {
|
||||||
window.location.href = "/Dashboard";
|
window.location.href = "<?= self::getUrl("Dashboard") ?>";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,8 @@ class UserProfileController extends mfBaseController
|
|||||||
|
|
||||||
protected function indexAction()
|
protected function indexAction()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->layout()->setTemplate("UserProfile/Index");
|
$this->layout()->setTemplate("UserProfile/Index");
|
||||||
$this->layout()->set("userprofile", $this->me);
|
$this->layout()->set("userprofile", $this->me);
|
||||||
// $email = new Emailnotification();
|
|
||||||
// $email->setSubject('testemail');
|
|
||||||
// $email->setBody('Testemail');
|
|
||||||
// $email->setTo('daniel.spitzer@inode.at');
|
|
||||||
// $email->send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addAction()
|
protected function addAction()
|
||||||
@@ -115,6 +109,7 @@ class UserProfileController extends mfBaseController
|
|||||||
$r = $this->request;
|
$r = $this->request;
|
||||||
$id = $this->me->id;
|
$id = $this->me->id;
|
||||||
$User = new User($id);
|
$User = new User($id);
|
||||||
|
$data = [];
|
||||||
if ($User->twofactor != 0) {
|
if ($User->twofactor != 0) {
|
||||||
$requestcode2fa = $r->code;
|
$requestcode2fa = $r->code;
|
||||||
$userCode2fa = $User->twofactorcode;
|
$userCode2fa = $User->twofactorcode;
|
||||||
@@ -125,10 +120,11 @@ class UserProfileController extends mfBaseController
|
|||||||
$this->layout()->setFlash("Verifizierungscode ungültig", "error");
|
$this->layout()->setFlash("Verifizierungscode ungültig", "error");
|
||||||
$this->redirect("UserProfile/edit");
|
$this->redirect("UserProfile/edit");
|
||||||
}
|
}
|
||||||
|
$data['twofactorcode'] = NULL;
|
||||||
|
$data['twofactortimestamp'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
|
||||||
$data['name'] = trim($r->name);
|
$data['name'] = trim($r->name);
|
||||||
if ($User->twofactor != 1) {
|
if ($User->twofactor != 1) {
|
||||||
$data['email'] = trim($r->email);
|
$data['email'] = trim($r->email);
|
||||||
@@ -184,7 +180,7 @@ class UserProfileController extends mfBaseController
|
|||||||
$this->layout()->setFlash("altes Passwort falsch", "error");
|
$this->layout()->setFlash("altes Passwort falsch", "error");
|
||||||
$this->redirect("UserProfile");
|
$this->redirect("UserProfile");
|
||||||
}
|
}
|
||||||
if (strlen($newpwd < 8)) {
|
if (strlen($newpwd) < 8) {
|
||||||
$this->layout()->setFlash("neues Passwort muss min. 8 Zeichen haben", "error");
|
$this->layout()->setFlash("neues Passwort muss min. 8 Zeichen haben", "error");
|
||||||
$this->redirect("UserProfile");
|
$this->redirect("UserProfile");
|
||||||
}
|
}
|
||||||
@@ -253,6 +249,9 @@ class UserProfileController extends mfBaseController
|
|||||||
$id = $this->me->id;
|
$id = $this->me->id;
|
||||||
$User = new User($id);
|
$User = new User($id);
|
||||||
$data['twofactor'] = $r->twofactor;
|
$data['twofactor'] = $r->twofactor;
|
||||||
|
$data['twofactorcode'] = NULL;
|
||||||
|
$data['twofactortimestamp'] = NULL;
|
||||||
|
|
||||||
$User->update($data);
|
$User->update($data);
|
||||||
$User->save();
|
$User->save();
|
||||||
$this->layout()->setFlash("Zwei-Faktor-Authentifizierung aktiv", "success");
|
$this->layout()->setFlash("Zwei-Faktor-Authentifizierung aktiv", "success");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
class UserToken extends mfBaseController
|
class UserToken extends mfBaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function checkToken()
|
public static function checkToken()
|
||||||
{
|
{
|
||||||
if (isset($_COOKIE[MFAPPNAME . '_remembertoken'])) {
|
if (isset($_COOKIE[MFAPPNAME . '_remembertoken'])) {
|
||||||
$cookie = explode(':', $_COOKIE[MFAPPNAME . '_remembertoken']);
|
$cookie = explode(':', $_COOKIE[MFAPPNAME . '_remembertoken']);
|
||||||
@@ -36,7 +36,7 @@ class UserToken extends mfBaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateToken($userId)
|
public static function generateToken($userId)
|
||||||
{
|
{
|
||||||
$db = new FronkDB();
|
$db = new FronkDB();
|
||||||
$tokenExpireTime = time() + 2592000;
|
$tokenExpireTime = time() + 2592000;
|
||||||
@@ -52,7 +52,7 @@ class UserToken extends mfBaseController
|
|||||||
setcookie(MFAPPNAME . '_remembertoken', $selector . ':' . $token, $tokenExpireTime, "/");
|
setcookie(MFAPPNAME . '_remembertoken', $selector . ':' . $token, $tokenExpireTime, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteToken()
|
public static function deleteToken()
|
||||||
{
|
{
|
||||||
$db = new FronkDB();
|
$db = new FronkDB();
|
||||||
$cookie = explode(':', $_COOKIE[MFAPPNAME . '_remembertoken']);
|
$cookie = explode(':', $_COOKIE[MFAPPNAME . '_remembertoken']);
|
||||||
|
|||||||
@@ -85,4 +85,15 @@ class UserTwofactor
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeCode()
|
||||||
|
{
|
||||||
|
$id = $this->UserId;
|
||||||
|
$User = new User($id);
|
||||||
|
$data = [];
|
||||||
|
$data['twofactorcode']=NULL;
|
||||||
|
$data['twofactortimestamp']=NULL;
|
||||||
|
$User->update($data);
|
||||||
|
$User->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -209,6 +209,8 @@ class mfLoginController extends mfBaseController
|
|||||||
#Token generieren in DB und Cookie schreiben
|
#Token generieren in DB und Cookie schreiben
|
||||||
UserToken::generateToken($userid);
|
UserToken::generateToken($userid);
|
||||||
}
|
}
|
||||||
|
$twoFactor = new UserTwofactor($userid);
|
||||||
|
$twoFactor->removeCode();
|
||||||
}
|
}
|
||||||
//session_name(MFAPPNAME."_session");
|
//session_name(MFAPPNAME."_session");
|
||||||
//session_start();
|
//session_start();
|
||||||
|
|||||||
Reference in New Issue
Block a user