Skip to content

Commit

Permalink
bug(middleware)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamadreza1388 committed Sep 11, 2024
1 parent 7784816 commit 893cc7b
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions app/Middleware/mvc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ class Admin extends Controller
{
public function before(): void
{
if (isset($_COOKIE['token'])) {
$header_token = $_COOKIE['token'];
$db = Flight::db();
$user_id = $db->prepare('SELECT `user_id` FROM tokens WHERE `token` = :token');
$user_id->execute([
':token' => $header_token,
]);
$user_id = $user_id->fetchAll();
$user_id = end($user_id)['user_id'];
$user = $db->prepare('SELECT * FROM users WHERE `id` = :user_id');
$user->execute([
':user_id' => $user_id,
]);
$user = $user->fetchAll();
$user = end($user);
if (intval($user['role_id']) !== 1) {
Flight::redirect("https://editor.salamlang.ir");
}
} else {
Flight::redirect("https://editor.salamlang.ir");
}

}
}

0 comments on commit 893cc7b

Please sign in to comment.