Skip to content

Commit 161ec94

Browse files
committed
add back login functionality for server - roll back to 4/10
1 parent a96022c commit 161ec94

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

classes/class.user.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@ public static function isLoggedIn()
1515
if (isset($_COOKIE['NFTOOLSID_'])) {
1616
return $userid;
1717
} else {
18-
$cstrong = True;
19-
$token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong));
20-
DatabaseConnector::query('INSERT INTO login_tokens (token, user_id) VALUES (:token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$userid));
21-
DatabaseConnector::query('DELETE FROM login_tokens WHERE token=:token', array(':token'=>sha1($_COOKIE['NFTOOLSID'])));
22-
echo 'got here';
23-
//$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
24-
$dynamic_url = /*$protocol . */ $_SERVER['HTTP_HOST'] . $GLOBALS["url_loc"][0];
25-
setcookie("NFTOOLSID", $token, time() + 60 * 60 * 24 * 7, '/', $dynamic_url, TRUE, TRUE);
26-
// create a second cookie to force the first cookie to expire without logging the user out, this way the user won't even know they've been given a new login toke
27-
setcookie("NFTOOLSID_", '1', time() + 60 * 60 * 24 * 3, '/', $dynamic_url, TRUE, TRUE);
28-
//get loggedin user id
29-
return $userid;
18+
$cstrong = True;
19+
$token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong));
20+
DatabaseConnector::query('INSERT INTO login_tokens (token, user_id) VALUES (:token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$userid));
21+
DatabaseConnector::query('DELETE FROM login_tokens WHERE token=:token', array(':token'=>sha1($_COOKIE['NFTOOLSID'])));
22+
setcookie("NFTOOLSID", $token, time() + 60 * 60 * 24 * 7, '/', 'nft-ools.com', TRUE, TRUE);
23+
// create a second cookie to force the first cookie to expire without logging the user out, this way the user won't even know they've been given a new login toke
24+
setcookie("NFTOOLSID_", '1', time() + 60 * 60 * 24 * 3, '/', ' nft-ools.com', TRUE, TRUE);
25+
//get loggedin user id
3026
}
3127
}
3228
}

0 commit comments

Comments
 (0)