From 16c0d34db7e6a0d56cdb00ebcfdd896fd1723783 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 30 May 2019 23:48:58 +0300 Subject: [PATCH] Flextype Box Plugin: Admin #125 #117 - Users Controller/Views implementation --- site/plugins/admin/app/Controllers/UsersConstroller.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site/plugins/admin/app/Controllers/UsersConstroller.php b/site/plugins/admin/app/Controllers/UsersConstroller.php index 7939335e..fb0a55fa 100644 --- a/site/plugins/admin/app/Controllers/UsersConstroller.php +++ b/site/plugins/admin/app/Controllers/UsersConstroller.php @@ -62,7 +62,7 @@ class UsersController extends Controller $data = $request->getParsedBody(); if (!Filesystem::has($_user_file = PATH['site'] . '/accounts/' . Text::safeString($data['username']) . '.json')) { - if (Filesystem::write( + if (Filesystem::write( PATH['site'] . '/accounts/' . $data['username'] . '.json', JsonParser::encode(['username' => Text::safeString($data['username']), 'hashed_password' => password_hash($data['password'], PASSWORD_BCRYPT), @@ -86,9 +86,11 @@ class Users { // Get Users Profiles $users = Filesystem::listContents(PATH['site'] . '/accounts/'); + // If any users exists then return true return ($users && count($users) > 0) ? true : false; } + public static function isLoggedIn() : bool { return (Session::exists('role') && Session::get('role') == 'admin') ? true : false;