Browse Source

move done & works

v3-dev
REJack 7 years ago
parent
commit
ecde5a85ee
  1. 3
      application/Config/Aauth.php
  2. 5
      application/Controllers/Home.php
  3. 8
      application/Controllers/Migrate.php
  4. 3
      application/Database/Migrations/20181026042034_create_ci_sessions_table.php
  5. 5
      application/Database/Migrations/20181026110732_create_users_table.php
  6. 5
      application/Database/Migrations/20181031062503_create_user_variables.php
  7. 5
      application/Database/Migrations/20181031063113_create_login_attempts.php
  8. 5
      application/Database/Migrations/20181031064211_create_groups.php
  9. 5
      application/Database/Migrations/20181031064431_create_group_to_user.php
  10. 5
      application/Database/Migrations/20181031064550_create_group_to_group.php
  11. 5
      application/Database/Migrations/20181031064714_create_perms.php
  12. 5
      application/Database/Migrations/20181031065111_create_perm_to_user.php
  13. 5
      application/Database/Migrations/20181031065240_create_perm_to_group.php
  14. 5
      application/Database/Migrations/20181031072542_create_default_groups.php
  15. 5
      application/Database/Migrations/20181031072914_create_default_admin.php
  16. 52
      application/Libraries/Aauth.php
  17. 7
      application/Models/Aauth/LoginAttemptModel.php
  18. 7
      application/Models/Aauth/UserModel.php
  19. 7
      application/Models/Aauth/UserVariableModel.php

3
application/Config/Aauth.php

@ -1,4 +1,5 @@
<?php namespace Magefly\Aauth\Config;
<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

5
application/Controllers/Home.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Controllers;
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Home extends Controller
{

8
application/Controllers/Migrate.php

@ -1,17 +1,17 @@
<?php namespace Magefly\Aauth\Controllers;
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use Magefly\Aauth\Config\Aauth as AauthConfig;
class Migrate extends Controller
{
public function index()
{
$config = new AauthConfig();
$config = new \Config\Aauth();
$migrate = \Config\Services::migrations();
try
{
$migrate->latest('Magefly\Aauth', $config->dbProfile);
$migrate->latest('App', $config->dbProfile);
}
catch (\Exception $e)
{

3
application/Database/Migrations/20181026042034_create_ci_sessions_table.php

@ -1,4 +1,5 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;

5
application/Database/Migrations/20181026110732_create_users_table.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_users_table extends Migration
{

5
application/Database/Migrations/20181031062503_create_user_variables.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_user_variables extends Migration
{

5
application/Database/Migrations/20181031063113_create_login_attempts.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_login_attempts extends Migration
{

5
application/Database/Migrations/20181031064211_create_groups.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_groups extends Migration
{

5
application/Database/Migrations/20181031064431_create_group_to_user.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_group_to_user extends Migration
{

5
application/Database/Migrations/20181031064550_create_group_to_group.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_group_to_group extends Migration
{

5
application/Database/Migrations/20181031064714_create_perms.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_perms extends Migration
{

5
application/Database/Migrations/20181031065111_create_perm_to_user.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_perm_to_user extends Migration
{

5
application/Database/Migrations/20181031065240_create_perm_to_group.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_perm_to_group extends Migration
{

5
application/Database/Migrations/20181031072542_create_default_groups.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_default_groups extends Migration
{

5
application/Database/Migrations/20181031072914_create_default_admin.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Database\Migrations;
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use Config\Aauth as AauthConfig;
class Migration_create_default_admin extends Migration
{

52
application/Libraries/Aauth.php

@ -1,5 +1,4 @@
<?php namespace Magefly\Aauth\Libraries;
<?php
/**
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
@ -8,27 +7,34 @@
*
* @package Aauth
* @author Magefly Team
* @author Jacob Tomlinson
* @author Tim Swagger (Renowne, LLC) <tim@renowne.com>
* @author Raphael Jackstadt <info@rejack.de>
*
* @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');

7
application/Models/Aauth/LoginAttemptModel.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Models;
<?php
namespace App\Models\Aauth;
use \CodeIgniter\Model;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use CodeIgniter\Model;
use Config\Aauth as AauthConfig;
class LoginAttemptModel extends Model
{

7
application/Models/Aauth/UserModel.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Models;
<?php
namespace App\Models\Aauth;
use \CodeIgniter\Model;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use CodeIgniter\Model;
use Config\Aauth as AauthConfig;
class UserModel extends Model
{

7
application/Models/Aauth/UserVariableModel.php

@ -1,7 +1,8 @@
<?php namespace Magefly\Aauth\Models;
<?php
namespace App\Models\Aauth;
use \CodeIgniter\Model;
use Magefly\Aauth\Config\Aauth as AauthConfig;
use CodeIgniter\Model;
use Config\Aauth as AauthConfig;
class UserVariableModel extends Model
{

Loading…
Cancel
Save