Skip to content

Commit

Permalink
Two Authentication Factor Send Email
Browse files Browse the repository at this point in the history
  • Loading branch information
Jave Lupango committed Dec 9, 2020
1 parent 7056211 commit ab12d4a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ RewriteRule ^home/([a-z0-9]+)/([a-z0-9]+) validate.php?data=$1&&data2=$2
RewriteRule ^home/([a-z0-9]+) validate.php?data=$1
RewriteRule ^home validate.php?data=home
RewriteRule ^logout logout.php
RewriteRule ^api/class/updateall class/api.authFunction.php


RewriteRule ^registerclass/([a-z0-9]+)/([a-z0-9]+) class/register.class.php?id=$1&&data=$2
7 changes: 6 additions & 1 deletion class/api.authFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
$c_con = new ClassConnection(); // connection declaration
$conn = $c_con->f_connection();
$c_Del->deleteRecord($conn, "UPDATE users SET duration = duration - 300 WHERE duration > 0 AND status='active'");
$c_Del->deleteRecord($conn, "UPDATE users SET duration = 0 WHERE duration < 0 OR status='delete'");
$c_Del->deleteRecord($conn, "UPDATE users SET duration = 0 WHERE duration < 0 OR status='delete'");

$c_Del->deleteRecord($conn, "DELETE FROM 2authfactor WHERE status='inactive'");
$c_Del->deleteRecord($conn, "UPDATE 2authfactor SET duration = duration - 300 WHERE duration > 0 AND status='active'");
$c_Del->deleteRecord($conn, "UPDATE 2authfactor SET duration = 0, status='inactive' WHERE duration <= 0");
$c_Del->deleteRecord($conn, "DELETE FROM 2authfactorlogs WHERE status='inactive'");
4 changes: 2 additions & 2 deletions controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ function insert_2authfactor_func($conn,$username, $code)
{
$now = new DateTime();
$dttime = $now->format('Y-m-d H:i:s');
$sql = "INSERT INTO 2authfactor (userid, status, code, dt)
VALUES ('$username', 'active', '$code', '$dttime')";
$sql = "INSERT INTO 2authfactor (userid, status, code, dt, duration)
VALUES ('$username', 'active', '$code', '$dttime', '900')";
$conn->exec($sql);
return "success";
}
Expand Down
4 changes: 2 additions & 2 deletions view/auth/2authfactor.front.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
</div>
</form>
<p class="mt-3 mb-1">
<a href="login">Login</a>
<a href="../login">Login</a>
</p>
<p class="mb-0">
<a href="register" class="text-center">Register a new membership</a>
<a href="../register" class="text-center">Register a new membership</a>
</p>
</div>
<!-- /.login-card-body -->
Expand Down
2 changes: 1 addition & 1 deletion view/auth/forgotpassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$content2 = "Do not share this email to others.";
$content3 = "Having trouble to log into your account? Just relay to your upline.";
$EmailContent = $c_email->email_Content_Func("Admin Panel", $resname, $resPass, $content1, $content2, $content3);
$resEmail = $c_email->sendEmailForgotPassword($resEmail, $EmailContent, "user101", "Reset Password");
$resEmail = $c_email->sendEmailForgotPassword($resEmail, $EmailContent, $resname, "Reset Password");
if ($resEmail == "send")
{
echo '<center><p style="color: blue;">Email Request Send! </p></center>';
Expand Down
8 changes: 7 additions & 1 deletion view/auth/login.front.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
{
$c_Auth->insert_2authfactorlogs($conn, md5($login_username), $login_username);
$genCode = $c_Func->GenerateUsername("CODE");
$c_Auth->insert_2authfactor_func($conn, md5($login_username), $genCode);
$c_Auth->insert_2authfactor_func($conn, md5($login_username), $genCode);
$g_email = $c_Select->fn_SingleResponse($conn, "SELECT * FROM users WHERE username=?", "email", $login_username);
$content1 = "You’re almost there! You have now enabled Two-Factor Authentication for your account and your login code is:";
$content2 = "The code will expire in 15 minutes.";
$content3 = "Having trouble to log into your account? Just relay to your upline.";
$EmailContent = $c_email->email_Content_Func("Admin Panel", $login_username, $genCode, $content1, $content2, $content3);
$resEmail = $c_email->sendEmailForgotPassword($g_email, $EmailContent, $login_username, "Two Factor Authentication");
header("Location: ".$url."/home/twoauthfactor/".md5($login_username));
}
}
Expand Down

0 comments on commit ab12d4a

Please sign in to comment.