Re: Using multiple criteria to login a user. Email or Username.

2009-11-15 Thread robustsolution
Dear Ahmed, how are you?

It is very very simple, you dont need to change anything in the Auth
component, anything in the login form

you just need to put this in the beforeFilter() callback of the users
controller
if ($this-params['action']=='login'  !array_key_exists
('requested',$this-params)  !empty($this-data[$this-Auth-
userModel])) {

$this-data[$this-Auth-userModel]=array_map('trim',$this-data
[$this-Auth-userModel]);

if(!empty($this-data[$this-Auth-userModel][$this-Auth-fields
['username']])  !empty($this-data[$this-Auth-userModel][$this-
Auth-fields['password']])) {
if 
(Validation::email($this-data[$this-Auth-userModel][$this-
Auth-fields['username']])) {

$this-data[$this-Auth-userModel]['email']=mb_strtolower($this-
data[$this-Auth-userModel][$this-Auth-fields['username']]);

unset($this-data[$this-Auth-userModel][$this-Auth-fields
['username']]);
$this-Auth-fields['username']='email';
}
}
}

please, have a nice baking day

--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Using multiple criteria to login a user. Email or Username.

2009-11-14 Thread David Roda
This will actually just change the form validation to make sure the username
is a valid email address, which I don't believe is his goal

On Sat, Nov 14, 2009 at 2:57 AM, merrylin shi shimeilin1...@gmail.comwrote:

 I know ,first cake bake the users table ,generate  the user.php ,open the
 files change the
 var $validate = array(
 'username' = array('notempty')
 );
 like
 var $validate = array(
 'username' = array('email')
 );

 just ok!

 2009/11/13 David Roda davidcr...@gmail.com

  To accomplish this you will have to override the Auth COmponents
 authorize variable and isAuthorized() method to check both the username
 and email.  You can read about it here:
 http://book.cakephp.org/view/396/authorize

 On Sat, Nov 14, 2009 at 12:40 AM, jburns jeremybu...@me.com wrote:

 Have you considered using the email address as the username (thereby
 eliminating your problem)?

 On Nov 14, 4:16 am, Ahmed ahmed.shar...@gmail.com wrote:
  Does anyone know how I can begin to tackle this feature?

 --

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=.



  --
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=.


  --
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=.


--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Using multiple criteria to login a user. Email or Username.

2009-11-13 Thread Ahmed
Does anyone know how I can begin to tackle this feature?

--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Using multiple criteria to login a user. Email or Username.

2009-11-13 Thread jburns
Have you considered using the email address as the username (thereby
eliminating your problem)?

On Nov 14, 4:16 am, Ahmed ahmed.shar...@gmail.com wrote:
 Does anyone know how I can begin to tackle this feature?

--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Using multiple criteria to login a user. Email or Username.

2009-11-13 Thread David Roda
To accomplish this you will have to override the Auth COmponents authorize
variable and isAuthorized() method to check both the username and email.
 You can read about it here: http://book.cakephp.org/view/396/authorize

On Sat, Nov 14, 2009 at 12:40 AM, jburns jeremybu...@me.com wrote:

 Have you considered using the email address as the username (thereby
 eliminating your problem)?

 On Nov 14, 4:16 am, Ahmed ahmed.shar...@gmail.com wrote:
  Does anyone know how I can begin to tackle this feature?

 --

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=.




--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.




Re: Using multiple criteria to login a user. Email or Username.

2009-11-13 Thread merrylin shi
I know ,first cake bake the users table ,generate  the user.php ,open the
files change the
var $validate = array(
'username' = array('notempty')
);
like
var $validate = array(
'username' = array('email')
);

just ok!

2009/11/13 David Roda davidcr...@gmail.com

 To accomplish this you will have to override the Auth COmponents
 authorize variable and isAuthorized() method to check both the username
 and email.  You can read about it here:
 http://book.cakephp.org/view/396/authorize

 On Sat, Nov 14, 2009 at 12:40 AM, jburns jeremybu...@me.com wrote:

 Have you considered using the email address as the username (thereby
 eliminating your problem)?

 On Nov 14, 4:16 am, Ahmed ahmed.shar...@gmail.com wrote:
  Does anyone know how I can begin to tackle this feature?

 --

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=.



  --
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/cake-php?hl=.


--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.