added login

This commit is contained in:
2022-06-07 22:03:52 +02:00
parent 430eaa8586
commit d12782ae5c
10 changed files with 190 additions and 10 deletions

34
app/scripts/functions.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
include("database_queries.php");
function check_login($con) {
if(isset($_SESSION['user_id'])) {
$id = $_SESSION['user_id'];
if(check_user_id($con, $id)) {
return get_user_data_id($con, $id);
} else {
header("Location: login.php");
die;
}
} else {
header("Location: login.php");
die;
}
}
function generate_salt() {
return substr(bin2hex(random_bytes(128)), 0, 128);
}
function generate_user_id($username, $salt) {
$uname = $username . $salt;
return hash('sha3-512', $uname);
}
function generate_password_hash($password, $salt) {
$pword = $password . $salt;
return hash('sha3-512', $pword);
}