Browse Source

added soft delete for users, groups & perms

- updated Config/Aauth
- updated GroupModel, PermModel & UserModel
- updated .env file for testing
v3-dev
REJack 6 years ago
parent
commit
7cf0a94445
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 3
      .env
  2. 21
      app/Config/Aauth.php
  3. 20
      app/Models/Aauth/GroupModel.php
  4. 20
      app/Models/Aauth/PermModel.php
  5. 10
      app/Models/Aauth/UserModel.php

3
.env

@ -14,6 +14,9 @@ migrations.enabled = true
aauth.dbProfile = 'tests'
aauth.loginRemember = '-1 day'
aauth.dbSoftDeleteUsers = true
aauth.dbSoftDeleteGroups = true
aauth.dbSoftDeletePerms = true
#--------------------------------------------------------------------
# APP

21
app/Config/Aauth.php

@ -341,6 +341,24 @@ class Aauth extends BaseConfig
|
| The table which contains permissions for groups
| (default: 'aauth_perm_to_group')
|
| 'dbSoftDeleteUsers'
|
| Enables soft delete for Users
| If this is enabled, it simply set a flag when rows are deleted.
| (default: false)
|
| 'dbSoftDeleteGroups'
|
| Enables soft delete for Groups
| If this is enabled, it simply set a flag when rows are deleted.
| (default: false)
|
| 'dbSoftDeletePerms'
|
| Enables soft delete for Perms
| If this is enabled, it simply set a flag when rows are deleted.
| (default: false)
*/
public $dbProfile = 'default';
public $dbTableUsers = 'aauth_users';
@ -353,4 +371,7 @@ class Aauth extends BaseConfig
public $dbTablePerms = 'aauth_perms';
public $dbTablePermToUser = 'aauth_perm_to_user';
public $dbTablePermToGroup = 'aauth_perm_to_group';
public $dbSoftDeleteUsers = true;
public $dbSoftDeleteGroups = true;
public $dbSoftDeletePerms = true;
}

20
app/Models/Aauth/GroupModel.php

@ -29,15 +29,6 @@ use Config\Aauth as AauthConfig;
*/
class GroupModel extends Model
{
/**
* If this model should use "softDeletes" and
* simply set a flag when rows are deleted, or
* do hard deletes.
*
* @var boolean
*/
protected $useSoftDeletes = true;
/**
* If true, will set created_at, and updated_at
* values during insert and update routines.
@ -60,12 +51,19 @@ class GroupModel extends Model
/**
* Constructor
*/
public function __construct()
public function __construct($db = null, $validation = null, $config = null)
{
parent::__construct();
$this->config = new AauthConfig();
if (is_null($config))
{
$config = new AauthConfig();
}
$this->config = $config;
$this->table = $this->config->dbTableGroups;
$this->DBGroup = $this->config->dbProfile;
$this->tempUseSoftDeletes = $this->config->dbSoftDeleteGroups;
$this->validationRules['name'] = 'required|is_unique[' . $this->table . '.name,id,{id}]';

20
app/Models/Aauth/PermModel.php

@ -29,15 +29,6 @@ use Config\Aauth as AauthConfig;
*/
class PermModel extends Model
{
/**
* If this model should use "softDeletes" and
* simply set a flag when rows are deleted, or
* do hard deletes.
*
* @var boolean
*/
protected $useSoftDeletes = true;
/**
* If true, will set created_at, and updated_at
* values during insert and update routines.
@ -60,12 +51,19 @@ class PermModel extends Model
/**
* Constructor
*/
public function __construct()
public function __construct($db = null, $validation = null, $config = null)
{
parent::__construct();
$this->config = new AauthConfig();
if (is_null($config))
{
$config = new AauthConfig();
}
$this->config = $config;
$this->table = $this->config->dbTablePerms;
$this->DBGroup = $this->config->dbProfile;
$this->tempUseSoftDeletes = $this->config->dbSoftDeletePerms;
$this->validationRules['name'] = 'required|is_unique[' . $this->table . '.name,id,{id}]';

10
app/Models/Aauth/UserModel.php

@ -29,15 +29,6 @@ use Config\Aauth as AauthConfig;
*/
class UserModel extends Model
{
/**
* If this model should use "softDeletes" and
* simply set a flag when rows are deleted, or
* do hard deletes.
*
* @var boolean
*/
protected $useSoftDeletes = true;
/**
* If true, will set created_at, and updated_at
* values during insert and update routines.
@ -97,6 +88,7 @@ class UserModel extends Model
$this->config = $config;
$this->table = $this->config->dbTableUsers;
$this->DBGroup = $this->config->dbProfile;
$this->tempUseSoftDeletes = $this->config->dbSoftDeleteGroups;
$this->validationRules['email'] = 'required|valid_email|is_unique[' . $this->table . '.email]';
$this->validationRules['password'] = 'required|min_length[' . $this->config->passwordMin . ']|max_length[' . $this->config->passwordMax . ']';

Loading…
Cancel
Save