BuLi-Tipp Login hinzugefügt und Rangliste angefangen
This commit is contained in:
36
bulitipp/login.php
Executable file
36
bulitipp/login.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
include("../../mysqlverbinden.php");
|
||||
include("../rowforeach.php");
|
||||
include("jwtsecret.php");
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
use Firebase\JWT\JWT;
|
||||
|
||||
|
||||
if(!isset($_GET["kuerzel"])) die("GET kuerzel fehlt");
|
||||
$kuerzel = $_GET['kuerzel'];
|
||||
|
||||
if(!isset($_GET["password"])) die("GET password fehlt");
|
||||
$password=$_GET["password"];
|
||||
|
||||
$userquery = srowforeach("SELECT `username`,`id`,`password` FROM `buli-user` WHERE `kuerzel`=?;", [$kuerzel]);
|
||||
if(count($userquery) == 0) {
|
||||
die("Benutzer nicht gefunden");
|
||||
}
|
||||
|
||||
if($password == $userquery[0][2]){
|
||||
// Passwort ist korrekt, weitermachen
|
||||
} else {
|
||||
die("Falsches Passwort");
|
||||
}
|
||||
|
||||
$payload = [
|
||||
"kuerzel" => $kuerzel,
|
||||
"exp" => time() + 3600,
|
||||
"username" => $userquery[0][0],
|
||||
"id" => $userquery[0][1]
|
||||
];
|
||||
$jwt = JWT::encode($payload, $secret, 'HS256');
|
||||
|
||||
echo $jwt;
|
||||
Reference in New Issue
Block a user