Changeset 21098
- Timestamp:
- 08/12/09 15:52:11 (4 years ago)
- Files:
-
- plugins/sfEasyAuthPlugin/trunk/README (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfEasyAuthPlugin/trunk/README
r21031 r21098 47 47 enabled_modules: [default, sfEasyAuth] 48 48 49 * Clear you cache49 * Clear your cache 50 50 51 51 $ symfony cc … … 53 53 * Optionally create a default user (the user type is case sensitive): 54 54 55 $ symfony easyAuth:create-user al 5ecret al@example.com basicUser55 $ symfony easyAuth:create-user al 5ecret1 al@example.com basicUser 56 56 57 57 * Optionally create a default admin user: 58 58 59 $ symfony easyAuth:create-user ally 5ecret ally@example.com admin59 $ symfony easyAuth:create-user ally 5ecret2 ally@example.com admin 60 60 61 61 Secure your application … … 207 207 208 208 [php] 209 $this->getUser()->get EasyAuthUser()->getUsername()209 $this->getUser()->getAuthUser()->getUsername() 210 210 211 211 // or via the proxy method … … 246 246 Adding more user types 247 247 ---------------------- 248 To add more user types, simply edit the schema.yml file, adding more entries under 249 `types`. E.g to add an `editor` user type, simply add an entry as below: 248 249 To add more user types, simply edit the app.yml file, adding more entries under 250 `schema_inheritance`. E.g to add an `editor` user type, simply add an entry as below: 250 251 251 252 [yml] 252 type: 253 type: varchar(10) 254 index: true 255 inheritance: 256 admin: sfEasyAuthAdmin 257 user: sfEasyAuthBasicUser 258 editor: sfEasyAuthEditor 259 253 schema_inheritance: # Credential inheritance definition for the plugin. 254 - admin: sfEasyAuthAdmin # These values will be inserted into the schema. 255 - basicUser: sfEasyAuthBasicUser # Keys are credential names, values are authentication 256 - editor: sfEasyAuthEditor # classes. 257 260 258 Any users that are created as editors will automatically acquire the `editor` credential 261 259 when they log in. … … 279 277 apply the restrictions, saving potentially costly database queries. 280 278 279 User profiles 280 ------------- 281 282 Extra data about users can be stored in a profile. As with other parts of Symfony, 283 convention is used instead of configuration. To create a profile for a user type, do 284 the following: 285 286 * If your classes are prefixed by a string of characters to act as a namespace, 287 edit the `profile_prefix` plugin app constant. These characters will be used to 288 compute the name of the profile class. 289 290 * Edit your main schema.yml file, creating an object with the same name as a user 291 type. e.g. if we declare an `editor` type as above and have a profile_prefix of 'my', 292 add something similar to below to your main `schema.yml` file: 293 294 [plain] 295 my_editor: 296 id: ~ 297 name: { type: varchar(200), required: true } 298 articles_edited: { type: int, default: 0 } 299 300 When you rebuild your model, you'll have a MyEditor class and peer class in your main 301 model directory. You can retrieve the profile as follows: 302 303 [php] 304 echo $sf_user->getAuthUser()->getProfile()->getName() . ' has edited ' . 305 $sf_user->getAuthUser()->getProfile()->getArticlesEdited() . ' articles'; 306 307 or more simply: 308 309 [php] 310 echo $sf_user->getProfile()->getName() . ' has edited ' . 311 $sf_user->getProfile()->getArticlesEdited() . ' articles'; 312 313 If you want to add more methods to the sfEasyAuthUserPeer class, it'd be better to 314 create a sub-class of it, and store your sub-class in your main lib directory somewhere. 315 This will ease your upgrade path in future should you choose to. 316 281 317 I18n 282 318 ---- 319 283 320 All error messages in templates can use the i18n framework. To enable translation of 284 321 error messages in actions, make sure you enable the I18n module in your `settings.yml` file. … … 287 324 Acknowledgements 288 325 ---------------- 326 289 327 Writing this plugin was made significantly easier thanks to sfGuardPlugin. Large parts of 290 328 this documentation come directly from the documentation for that plugin, and some code was