LoginLogout
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user