From ecde5a85ee081e9d62c4625ab31a8fb3972331c3 Mon Sep 17 00:00:00 2001 From: REJack Date: Tue, 13 Nov 2018 17:37:53 +0100 Subject: [PATCH] move done & works --- application/Config/Aauth.php | 3 +- application/Controllers/Home.php | 5 +- application/Controllers/Migrate.php | 8 +-- ...0181026042034_create_ci_sessions_table.php | 3 +- .../20181026110732_create_users_table.php | 5 +- .../20181031062503_create_user_variables.php | 5 +- .../20181031063113_create_login_attempts.php | 5 +- .../20181031064211_create_groups.php | 5 +- .../20181031064431_create_group_to_user.php | 5 +- .../20181031064550_create_group_to_group.php | 5 +- .../20181031064714_create_perms.php | 5 +- .../20181031065111_create_perm_to_user.php | 5 +- .../20181031065240_create_perm_to_group.php | 5 +- .../20181031072542_create_default_groups.php | 5 +- .../20181031072914_create_default_admin.php | 5 +- application/Libraries/Aauth.php | 52 +++++++++++-------- .../Models/Aauth/LoginAttemptModel.php | 7 +-- application/Models/Aauth/UserModel.php | 7 +-- .../Models/Aauth/UserVariableModel.php | 7 +-- 19 files changed, 85 insertions(+), 62 deletions(-) diff --git a/application/Config/Aauth.php b/application/Config/Aauth.php index db2ea08..70ba1a6 100644 --- a/application/Config/Aauth.php +++ b/application/Config/Aauth.php @@ -1,4 +1,5 @@ -latest('Magefly\Aauth', $config->dbProfile); + $migrate->latest('App', $config->dbProfile); } catch (\Exception $e) { diff --git a/application/Database/Migrations/20181026042034_create_ci_sessions_table.php b/application/Database/Migrations/20181026042034_create_ci_sessions_table.php index 891a1c6..f632d13 100644 --- a/application/Database/Migrations/20181026042034_create_ci_sessions_table.php +++ b/application/Database/Migrations/20181026042034_create_ci_sessions_table.php @@ -1,4 +1,5 @@ - + * @author Raphael Jackstadt + * + * @copyright 2014-2017 Emre Akay * @copyright 2018 Magefly - * @copyright 2014-2018 British Columbia Institute of Technology (https://bcit.ca/) * @license https://opensource.org/licenses/MIT MIT License * @link https://github.com/magefly/CodeIgniter-Aauth * @version 3.0.0-pre - * - * @todo separate (on some level) the unvalidated users from the "banned" users */ + +namespace App\Libraries; +use \App\Models\Aauth\UserModel as UserModel; +use \App\Models\Aauth\LoginAttemptModel as LoginAttemptModel; +use \App\Models\Aauth\UserVariableModel as UserVariableModel; class Aauth { /** * Variable for loading the config array into * - * @var object + * @var \Config\Aauth */ private $config; /** * Variable for loading the session service into * - * @var object + * @var \CodeIgniter\Session\Session */ private $session; @@ -85,7 +91,7 @@ class Aauth */ function __construct() { - $this->config = new \Magefly\Aauth\Config\Aauth(); + $this->config = new \Config\Aauth(); $this->session = \Config\Services::session(); } @@ -102,12 +108,12 @@ class Aauth */ public function createUser($email, $password, $username = null) { - $userModel = new \Magefly\Aauth\Models\UserModel(); + $userModel = new UserModel(); $data['email'] = $email; $data['password'] = $password; - if ($username) + if ( ! is_null($username)) { $data['username'] = $username; } @@ -135,7 +141,7 @@ class Aauth */ public function updateUser($userId, $email = null, $password = null, $username = null) { - $userModel = new \Magefly\Aauth\Models\UserModel(); + $userModel = new UserModel(); $data = []; if ( ! $userModel->existsById($userId)) @@ -143,24 +149,24 @@ class Aauth $this->error(lang('Aauth.notFoundUser')); return false; } - else if ( ! $email && ! $password && ! $username) + else if ( ! is_null($email) && ! is_null($password) && ! is_null($username)) { return false; } $data['id'] = $userId; - if ($email) + if ( ! is_null($email)) { $data['email'] = $email; } - if ($password) + if ( ! is_null($password)) { $data['password'] = $password; } - if ($username) + if ( ! is_null($username)) { $data['username'] = $username; } @@ -180,7 +186,7 @@ class Aauth */ public function deleteUser(int $userId) { - $userModel = new \Magefly\Aauth\Models\UserModel(); + $userModel = new UserModel(); $data = []; if ( ! $userModel->existsById($userId)) @@ -208,20 +214,20 @@ class Aauth * * @return array Array of users */ - public function listUsers(int $limit = 0, int $offset = 0, bool $includeBanneds = null, array $orderBy = null) + public function listUsers($limit = 0, $offset = 0, $includeBanneds = null, $orderBy = null) { - $userModel = new \Magefly\Aauth\Models\UserModel(); + $userModel = new UserModel(); $options = []; $user = $userModel->limit($limit, $offset); // bool $group_par = null, - if ( ! $includeBanneds) + if (is_null($includeBanneds)) { $user->where('banned', 0); } - if ($orderBy) + if ( ! is_null($orderBy)) { $user->orderBy($orderBy[0], $orderBy[1]); } @@ -248,9 +254,9 @@ class Aauth */ public function login(string $identifier, string $password, bool $remember = null, bool $totpCode = null) { - $userModel = new \Magefly\Aauth\Models\UserModel(); - $loginAttemptModel = new \Magefly\Aauth\Models\LoginAttemptModel(); - $userVariableModel = new \Magefly\Aauth\Models\UserVariableModel(); + $userModel = new UserModel(); + $loginAttemptModel = new LoginAttemptModel(); + $userVariableModel = new UserVariableModel(); helper('cookie'); delete_cookie('user'); diff --git a/application/Models/Aauth/LoginAttemptModel.php b/application/Models/Aauth/LoginAttemptModel.php index 0d9f312..7e6f469 100644 --- a/application/Models/Aauth/LoginAttemptModel.php +++ b/application/Models/Aauth/LoginAttemptModel.php @@ -1,7 +1,8 @@ -