-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* specify version for ui * add changelog * typo fix * Add a lot of comments in code and also some hooks and ease customization of encryption/verification methods by using callbacks * no need for new instance, fix #10 * demos fix, no need for config * initial implementation of acl * add missing bits * cleanup cloning * In Case the project is used as component This raises warning/notice if Auth and Atk is used as components in any other frameworks * Update Auth.php * Update Auth.php * work in progress - working on new version * wip * work in progress * extended admin to manage role rules * Fix log-in page title When login appears, currently the title is "Agile UI - Untitled Application". This changes the title to "Log-in Required". * Allow title customization Added $title field. Title can be customized by passing it into the constructor like this: `new Login/Auth(['title' => 'Please login'])` * Compact code * Revert and use $this-app->title * update dependencies * fix password field cloning and tests * bunch of changes mostly in models * make demo config configurable * wip in demos * comment * wip * sublime * wip * cleanup * no need for password to be visible * in progress * kind of done * address Romans comments * ACL UI, fields and actions dropdown etc * comment * Fix/wizard2.0.0 - WIP (#22) * Update .travis.yml * rollback to dev-develop (atk4/data@dev-feature was merged) * fix Demo with correct namespace for Demo App * Add Form to test and create file config.php for connection to db * Temporary fix to atk4\schema\migrateModels method * Fix : if file config.php not present redirect to wizard.php * Fix : action "register_new_user" field : login -> name * composer : pinned atk repos version to 2.0.* * clean up * setup travis for 7.2 + coverage * few tweaks (#23) * tests config * few tweaks * use render method only if model is set (#24) * done (#25) * fix dropdowns (#26) * Update AbstractDropDown.php * Update AccessRule.php * develop branch should rely on develop branches * Feature/add release workflow (#27) * add release scripts * implement "require-release" strategy suggested by Dark * remove behat, it is not working anyway * remove behat, it is not working anyway * codecov fix * whops * fix * fix * fix * fix * fix * fix ACL * move functionality to setup trait * change traits * bump test * bump atk4/schema version * Setting release dependencies Co-authored-by: Romans Malinovskis <me@nearly.guru> Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com> Co-authored-by: Gowrav Vishwakarma <gowravvishwakarma@gmail.com> Co-authored-by: Alex Cicovic <acicovic@gmail.com> Co-authored-by: Francesco Danti <fdanti@gmail.com> Co-authored-by: GitHub Web Flow <noreply@github.com>
- Loading branch information
1 parent
2bebb00
commit b0bbc14
Showing
8 changed files
with
139 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
namespace atk4\login\Feature; | ||
|
||
/** | ||
* Adding this trait to your atk4/login models will properly setup these models for your application. Additionally execute | ||
* $this->setupModel() from your models init() method after you define model fields. | ||
* | ||
* @package atk4\login\Feature | ||
*/ | ||
use atk4\login\Model\AccessRule; | ||
use atk4\login\Model\Role; | ||
use atk4\login\Model\User; | ||
|
||
use atk4\login\FormField; | ||
|
||
trait SetupModel | ||
{ | ||
/** | ||
* Setup AccessRule model. | ||
*/ | ||
public function setupAccessRuleModel() | ||
{ | ||
$this->getField('model')->required = true; | ||
$this->getField('model')->caption = 'Model Class'; | ||
|
||
/* | ||
$this->containsOne('config', new class extends Model { | ||
public function init() | ||
{ | ||
parent::init(); | ||
// We can put all fields which are below in here. | ||
// And this new class should be separated to let's say AccessRule/Model class so we can | ||
// also have AccessRule/Interface or AccessRule/View or AccessRule/Page class in future | ||
// with different config properties | ||
} | ||
}); | ||
*/ | ||
|
||
$this->getField('all_visible')->default = true; | ||
$this->getField('all_editable')->default = true; | ||
$this->getField('all_actions')->default = true; | ||
|
||
$this->getField('visible_fields')->ui['form'] = FormField\FieldsDropDown::class; | ||
$this->getField('editable_fields')->ui['form'] = FormField\FieldsDropDown::class; | ||
$this->getField('actions')->ui['form'] = FormField\ActionsDropDown::class; | ||
$this->getField('conditions')->type = 'text'; | ||
|
||
// cleanup data | ||
$this->addHook('beforeSave', function ($m) { | ||
if ($m['all_visible']) $m['visible_fields'] = null; | ||
if ($m['all_editable']) $m['editable_fields'] = null; | ||
if ($m['all_actions']) $m['actions'] = null; | ||
}); | ||
} | ||
|
||
/** | ||
* Setup Role model. | ||
*/ | ||
public function setupRoleModel() | ||
{ | ||
$this->getField('name')->required = true; | ||
$this->setUnique('name'); | ||
} | ||
|
||
/** | ||
* Setup User model. | ||
*/ | ||
public function setupUserModel() | ||
{ | ||
$this->getField('name')->required = true; | ||
$this->getField('email')->required = true; | ||
$this->setUnique('email'); | ||
$this->getField('password')->ui['visible'] = false; | ||
|
||
// all AccessRules for all user roles | ||
// @TODO in future when there can be multiple, then merge them together | ||
$this->hasMany('AccessRules', [ | ||
function ($m) { | ||
return $m->ref('role_id')->ref('AccessRules'); | ||
}, | ||
'our_field' => 'role_id', | ||
'their_field' => 'role_id', | ||
]); | ||
|
||
// add some validations | ||
$this->addHook('beforeSave', function ($m){ | ||
// password should be set when trying to insert new record | ||
// but it can be empty if you update record (then it will not change password) | ||
if (!$m->loaded() && !$m->get('password')) { | ||
throw new ValidationException(['password' => 'Password is required'], $this); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters