Development

Changeset 21098

You must first sign up to be able to contribute.

Changeset 21098

Show
Ignore:
Timestamp:
08/12/09 15:52:11 (4 years ago)
Author:
allyb
Message:

Updated the README

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfEasyAuthPlugin/trunk/README

    r21031 r21098  
    4747                enabled_modules:      [default, sfEasyAuth] 
    4848 
    49   * Clear you cache 
     49  * Clear your cache 
    5050 
    5151        $ symfony cc 
     
    5353  * Optionally create a default user (the user type is case sensitive): 
    5454 
    55         $ symfony easyAuth:create-user al 5ecret al@example.com basicUser 
     55        $ symfony easyAuth:create-user al 5ecret1 al@example.com basicUser 
    5656 
    5757  * Optionally create a default admin user: 
    5858 
    59         $ symfony easyAuth:create-user ally 5ecret ally@example.com admin 
     59        $ symfony easyAuth:create-user ally 5ecret2 ally@example.com admin 
    6060 
    6161Secure your application 
     
    207207 
    208208    [php] 
    209     $this->getUser()->getEasyAuthUser()->getUsername() 
     209    $this->getUser()->getAuthUser()->getUsername() 
    210210 
    211211    // or via the proxy method 
     
    246246Adding more user types 
    247247---------------------- 
    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 
     249To 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: 
    250251 
    251252    [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             
    260258Any users that are created as editors will automatically acquire the `editor` credential 
    261259when they log in. 
     
    279277apply the restrictions, saving potentially costly database queries. 
    280278 
     279User profiles 
     280------------- 
     281 
     282Extra data about users can be stored in a profile. As with other parts of Symfony,  
     283convention is used instead of configuration. To create a profile for a user type, do 
     284the 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       
     313If you want to add more methods to the sfEasyAuthUserPeer class, it'd be better to  
     314create a sub-class of it, and store your sub-class in your main lib directory somewhere. 
     315This will ease your upgrade path in future should you choose to.  
     316 
    281317I18n 
    282318---- 
     319 
    283320All error messages in templates can use the i18n framework. To enable translation of  
    284321error messages in actions, make sure you enable the I18n module in your `settings.yml` file. 
     
    287324Acknowledgements 
    288325---------------- 
     326 
    289327Writing this plugin was made significantly easier thanks to sfGuardPlugin. Large parts of  
    290328this documentation come directly from the documentation for that plugin, and some code was