LoginLogout

This commit is contained in:
2024-07-21 15:49:43 +02:00
parent 132e8790a3
commit 8d91e805dd
10 changed files with 293 additions and 51 deletions
+16 -2
View File
@@ -2,11 +2,25 @@
namespace Api\Login;
use Exception;
use Khofmann\Input\Input;
class Login
{
public function post()
{
echo "LOGIN HANDLER post";
print_r(input()->all());
try {
$response = \Khofmann\Models\User\User::logIn(Input::post("email"), Input::post("password"));
return json_encode($response);
} catch (Exception $err) {
switch ($err->getMessage()) {
case "Failed":
throw new Exception("Login failed", 500);
case "NotFound":
throw new Exception("User not Found", 404);
case "Invalid":
throw new Exception("Invalid Username or Password", 401);
}
}
}
}