mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-09 19:52:28 +01:00
more refactoring
This commit is contained in:
parent
192015304d
commit
ecd6ca01f9
@ -10,18 +10,17 @@ require_once 'lib-auth.php'; // require auth libs
|
||||
require_once 'helpers/helper-mailsend.php'; // require mail libs
|
||||
require_once 'lib-password.php'; // require password encryption libs
|
||||
require_once 'fpasslib.php'; // require fpass functions
|
||||
// require_once('ayah.php');
|
||||
|
||||
$polrauth = new polrauth();
|
||||
$fpass = new fpass();
|
||||
require_once 'layout-headerlg.php';
|
||||
if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey']) && isset($_POST['cuser'])) {
|
||||
// if submitting new pw
|
||||
// if submitting new password
|
||||
$ckey = $mysqli->real_escape_string($_POST['crkey']);
|
||||
$rnpass = $mysqli->real_escape_string($_POST['rnpass']);
|
||||
$cuser = $mysqli->real_escape_string($_POST['cuser']);
|
||||
$npass = $mysqli->real_escape_string($_POST['npass']);
|
||||
$userinfoc = $polrauth->getinfomu($cuser); // fetch info
|
||||
$userinfoc = $polrauth->getinfomu($cuser); // fetch the user's information
|
||||
if ($userinfoc == false) {
|
||||
echo "<h2>That username is not associated with any account. Please try again.</h2>"
|
||||
. "<br />"
|
||||
@ -36,16 +35,18 @@ if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey'])
|
||||
require_once 'layout-footerlg.php';
|
||||
die();
|
||||
}
|
||||
if ($userinfoc['rkey'] == $_POST['crkey']) { // if rkey & user check out
|
||||
if ($userinfoc['rkey'] == $_POST['crkey']) {
|
||||
// if the rkey is correct
|
||||
if ($npass != $rnpass) {
|
||||
// if new pass & repeat don't match
|
||||
require_once 'layout-headerlg.php';
|
||||
echo "<h2>Passwords don't match. Try again. (click the link in the email again)</h2>";
|
||||
require_once 'layout-footerlg.php';
|
||||
die();
|
||||
} else { // all checks out
|
||||
$fpass->changepass($npass, $cuser); // change pass
|
||||
$polrauth->crkey($cuser); //change rkey
|
||||
} else {
|
||||
// everything is as expected, perform password reset
|
||||
$fpass->changepass($npass, $cuser); // update the user's password
|
||||
$polrauth->crkey($cuser); // update their reset token
|
||||
require_once 'layout-headerlg.php';
|
||||
echo "<h2>Password changed.</h2>";
|
||||
require_once 'layout-footerlg.php';
|
||||
@ -56,7 +57,7 @@ if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey'])
|
||||
$fpass = new fpass();
|
||||
if (isset($_GET['key']) && isset($_GET['username'])) {
|
||||
$username = $mysqli->real_escape_string($_GET['username']);
|
||||
$userinfoc = $polrauth->getinfomu($username); // fetch info
|
||||
$userinfoc = $polrauth->getinfomu($username);
|
||||
if ($userinfoc == false) {
|
||||
echo "<h2>That username is not associated with any account. Please try again.</h2>"
|
||||
. "<br />"
|
||||
@ -65,13 +66,12 @@ if (isset($_GET['key']) && isset($_GET['username'])) {
|
||||
die();
|
||||
}
|
||||
if ($userinfoc == false) {
|
||||
// if user does not exist
|
||||
// if the user does not exist
|
||||
require_once 'layout-headerlg.php';
|
||||
echo "<h2>User or key invalid or already used.</h2>";
|
||||
require_once 'layout-footerlg.php';
|
||||
die();
|
||||
}
|
||||
//var_dump($userinfoc);
|
||||
if ($userinfoc['rkey'] == $_GET['key']) {
|
||||
require_once 'layout-headerlg.php';
|
||||
echo "<h2>Change Password for {$_GET['username']}</h2>";
|
||||
@ -88,13 +88,9 @@ if (isset($_GET['key']) && isset($_GET['username'])) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (isset($_POST['username']) == true && isset($_POST['key']) == true) {
|
||||
}
|
||||
*/
|
||||
|
||||
@$email = $_POST['email'];
|
||||
if (!$email) {
|
||||
// if requesting form
|
||||
echo "<h2>Forgot your password?</h2>"
|
||||
. "<br/ >"
|
||||
. "<form action='forgotpass.php' method='POST' style='margin:0 auto; width: 450px'>"
|
||||
@ -125,6 +121,6 @@ if ($userinfo == false) {
|
||||
}
|
||||
$rkey = $userinfo['rkey'];
|
||||
$username = $userinfo['username'];
|
||||
$fpass->sendfmail($email, $username, $rkey); // send the email
|
||||
$fpass->sendfmail($email, $username, $rkey);
|
||||
echo "Email successfully sent. Check your inbox for more info.";
|
||||
require_once 'layout-footerlg.php';
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// includes for forgotpassword functions
|
||||
// includes for password resets
|
||||
require_once 'helpers/helper-mailsend.php';
|
||||
require_once 'lib-auth.php';
|
||||
require_once 'lib-core.php';
|
||||
@ -20,7 +20,7 @@ class fpass {
|
||||
. "<br />"
|
||||
. "Cheers,<br />"
|
||||
. "The {$wsn} Team<br />";
|
||||
$sgmail->sendmail($to, $subject, $message); //actually send the email
|
||||
$sgmail->sendmail($to, $subject, $message); // send email
|
||||
}
|
||||
public function hash($pass) {
|
||||
$opts = [
|
||||
|
Loading…
Reference in New Issue
Block a user