php - CakePhp Auth : Questions -


I have to do a cake php certification, and I want to use the "audio" component. I am trying to see that it fills my requirement:

  • I need to authenticate users with their email or their customer ID (except for the course With password). I do not know if there can be two fields (or more) that can be authenticated

  • I have several parts to which I should get authenticated. But I need different granurity:

    • For some things, this is the entire controller, which should not be accessible (with the exception of if possible (like all "users"
    • Sometimes I need that some actions are unavailable without logging out
    • Sometimes I only need one part The scene is not displayed (u The login element is not displayed for the alarm)
    • Does the component act like password changes? Because if the user changes his password then I need that

      In short, the answer is Yes, you can do this work, but I think ACL can be as much as possible for your needs (but I also want to avoid ACL If Ivo suggests, you can use a custom UsersController to authenticate through several fields:

      • : Login () method will be required (if your ethnic model is not user , then use the appropriate administrator). If the AUTH component's login method fails, it passes under control of your custom login () method here: The project I'm working on is a snippet:

          function login () {# username (legacy) or allow login by email # If an authenticated user is not present at this point then the entry () method of the element # of the element # 1 has failed and the control # Given for any further handle has gone. Since the required credentials # (email and password) have failed we are going to check # username and password $ user = $ this- & gt; AUTH- & gt; the user (); If (empty ($ user) & amp; empty ($ this-> AUTH- & gt; data ['user'] ['' email ']) & amp; empty! ($-> Auth- & Gt; data ['user'] ['password'])) {$ user = $ this- & gt; User- & gt; Search ('first', array ('recursive' => gt; -1, 'conditions' => array (' User.username '= & gt; $ this-> AUTH- & gt; data [' User '] [' email '],' user password '=> $ the-> authorization-> data [' user password '],))); If (empty ($ user) ||! $ This-> AUTH- & gt; login ($ user)) {# Configure Flash Memory B / C Login failed after both checks. $ This- & gt; Session-> Set Flash ($ this-> AUTH- & gt; Login Error, Blank, Array (), 'auth'); }} $ This-> Redirect ($ this-> AUTH- & gt; redirect (), empty, true); }    
      • To access the action, simply enter $ this-> Auth-> This- & gt; AUTH- & gt; Disclaimer () For each relevant controller's beforeFilter () callback example, in UsersController , you might want to do something like this:

          Filter () before public function (parent: beforeFilter (); $ This- & gt; Auth-> Refuse ( '*'); $ This- & gt; AUTH- & gt; Allow ('Login', 'Logout'); }    
      • In the ideas, determine that the Auth.User to determine what a user finds / hide / Whether the value is authenticated by testing or not. From anonymous / authenticated:

          If ($ this-> session-> Check ('auth.User')) {...}    
      • If the password changes, you can change the user to $ this-> Auth-> Can be certified transparently by calling the login ($ user_data) . I do this, for example, when a user registers, I do not want to be logged in, so I'm just a login myself.

      Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -