Mark Scherer 10 年 前
コミット
5d430dc609
2 ファイル変更42 行追加1 行削除
  1. 41 0
      docs/Auth/Auth.md
  2. 1 1
      docs/README.md

+ 41 - 0
docs/Auth/Auth.md

@@ -0,0 +1,41 @@
+# Auth functionality
+
+The Tools plugin contains some convenience wrappers to work with Auth user data.
+They have a trait in common that keeps the functionality DRY.
+
+## AuthUser Component
+Attach it to your controllers in `initialize()` like so:
+```php
+$this->loadComponent('Tools.AuthUser');
+```
+
+## AuthUser Helper
+Load your helper in your View class or use the controller property:
+```php
+$this->loadHelper('Tools.AuthUser');
+
+// or
+public $helpers = ['Tools.AuthUser'];
+```
+Don't forget that the component has to be included for the helper to function.
+
+
+## Usage
+Both component and helper function the same:
+
+```php
+// Read the id of the logged in user as shortcut method (Auth.User.id)
+$uid = $this-AuthUser->id();
+
+// Get the username (Auth.User.username)
+$username = $this->AuthUser->user('username');
+
+// Check for a specific role
+$roles = $this->AuthUser->roles();
+
+// Check for a specific role
+$hasRole = $this->AuthUser->hasRole(ROLE_XYZ);
+
+## Notes
+The above example uses default settings and ROLE_{...} constants.
+Use your own settings if necessary to overwrite the default behavior.

+ 1 - 1
docs/README.md

@@ -18,7 +18,7 @@ This cake3 branch only works for **CakePHP3.x** - please use the master branch f
 * [Behavior/Reset](Behavior/Reset.md)
 * [Behavior/Reset](Behavior/Reset.md)
 * [Component/Flash](Component/Flash.md)
 * [Component/Flash](Component/Flash.md)
 * [View/Rss](View/Rss.md)
 * [View/Rss](View/Rss.md)
-* ...
+* [Auth (Component/Helper)](Auth/Auth.md)
 * [Testing](TestSuite/Testing.md)
 * [Testing](TestSuite/Testing.md)
 
 
 ## Basic enhancements of the core
 ## Basic enhancements of the core