-
-
Save jameshilliard/ccd7f3d2bf2570cded35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!empty($_POST)) { | |
$errors = array(); | |
if (empty($_POST['username'])) { | |
$errors['username'] = 'Username cannot be empty'; | |
} else { | |
$ans = checkPass(strtolower($_POST['username']), $_POST['password'], $_POST['2fa']); | |
if (strpos($ans,'failed') !== false) { | |
if (get2fa($_POST['username'], '', 0, 0)['2fa_status'] === "ok") { | |
$errors['2fa'] = 'This account requires 2FA'; | |
} | |
$errors['login_failed'] = true; | |
} | |
} | |
if (empty($errors)) { | |
$_SESSION['username'] = strtolower($_POST['username']); | |
session_regenerate_id(); | |
header("HTTP/1.0 401 Unauthorized"); | |
header('Location: index.php?p=dashboard'); | |
exit(); | |
} | |
} else if (!empty($_SESSION['username'])) { | |
header("HTTP/1.0 401 Unauthorized"); | |
header('Location: index.php?p=dashboard'); | |
exit(); | |
} | |
?> | |
<div class="page-title"> | |
<div class="container"> | |
<h2>Sign in</h2> | |
</div> | |
</div> | |
<!-- BEGIN LOGIN --> | |
<div class="login content"> | |
<?php if (!empty($errors)) { ?> | |
<div class="page-notice"> | |
<p class="alert alert-danger">Incorrect Login</p> | |
</div> | |
<?php } ?> | |
<form id="login-form" class="login-form auth-form" action="/index.php?p=login" method="post"> | |
<h3 class="form-title"><span>Sign In to your account</span></h3> | |
<div class="form-body"> | |
<div class="form-group field-loginform-username required"> | |
<div class="input-icon"> | |
<i class="fa fa-user"></i><input type="text" id="loginform-username" class="input-lg form-control" name="username" placeholder="Username" <?=(!empty($_POST['username']) ? 'value="'.$_POST['username'].'"':'')?>> | |
</div> | |
<?php if (!empty($errors['username'])) { ?><p class="help-block help-block-error"><?=$errors['username']?></p><?php } ?> | |
</div> | |
<div class="form-group field-loginform-password required"> | |
<div class="input-icon"> | |
<i class="fa fa-unlock"></i><input type="password" id="loginform-password" class="input-lg form-control input-password" name="password" placeholder="Password"> | |
</div> | |
</div> | |
<div class="form-group field-loginform-2fa required"> | |
<div class="input-icon"> | |
<i class="fa fa-phone-square"></i><input type="password" id="loginform-2fa" class="input-lg form-control input-2fa" name="2fa" placeholder="Two-Factor Authentication"> | |
</div> | |
<?php if (!empty($errors['2fa'])) { ?><p class="help-block help-block-error"><?=$errors['2fa']?></p><?php } ?> | |
<p class="help-block help-block-error" style="padding: 0px 20px;">* Leave this blank if you have not enabled 2FA</p> | |
</div> | |
<div class="form-actions clearfix text-center"> | |
<button type="submit" class="btn yellow uppercase">Sign in <i class="fa fa-chevron-right"></i></button> | |
</div> | |
</div> | |
<div class="form-footer"> | |
<div class="forget-password"> | |
<p> | |
Forget your password? - <a href="/index.php?p=forgot">Click Here to reset</a> | |
<br /> | |
Don't have an account yet? - <a href="/index.php?p=register">Register Here</a> | |
</p> | |
</div> | |
</div> | |
</form> | |
</div> | |
<!-- END LOGIN --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment