37 lines
867 B
PHP
Executable File
37 lines
867 B
PHP
Executable File
<?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;
|