Jump to content
Larry Ullman's Book Forums

Raymien

Members
  • Posts

    4
  • Joined

  • Last visited

Raymien's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi Edward, I think you may have missed part of this topic. I'm using email authentication, rather than username authentication, in which the username is replaced by email in the user creation. Ray
  2. Maybe I should step back a bit, and trace the login process, which starts with LoginForm: $this->_identity=new UserIdentity($this->username,$this->password); //becomes $this->_identity=new UserIdentity($this->email,$this->password); UserIdentity is the component which incorporates the new db authenticate function, and Larry clearly shows/reminds us that email is now username. // Understand that email === username $user = User::model()->findByAttributes(array('email'=>$this->username)); Now, if I understand correctly, $user is the local variable accessing the user model ($user = User::model()), and that if I want $user to include username, I'd need to modify the model. That's the part I'm confused about. (sorry if I seem to be rambling, I'm trying to sort through this again in my head.) Maybe it would be easier to just query the db to get the proper username that matches the email, and construct the User with that, then validate the password? Push me in the right direction please, I think I'm starting to get a headache. Ray
  3. Yes, the code is not complete, but it would be nice to know the password you used on the sample data. :-) it does appear to be all the same password though. Drumroll please, the password is "password" ;-) Ray
  4. Hello boys and girls, I've been looking at a way to maintain access to the user name when using the Custom Authentication by email, as explained in the book. I think logging in via email is a good idea, as I still have members to our Curling site, who are quite forgetful of their usernames, but email's tend to not change. That being said, I've got at least one player who has actually gotten himself 3 different user accounts, because he forgets his username. On the flip side, many folks like to be called by their names, be it a pseudonym, or their actual name, rather than johnny274@gmail.com. So I tried what I thought would work, by setting the username much in the same way as the id as shown in the book. It didn't work. Then I noticed in the blog, a commenter asked a similar question (Josh) and found a solution that worked for him. Which was surprising similar to what I thought would work. So I tried that, and it still didn't work. So obviously I'm missing something. To note, I have been coding for many years now, longer than I care to admit, but I'm kinda new to the Yii framework, so please be gentle! Here's the code: UserIdentity private $_name; . . . //within the authenticate function $this->_name = $user->username; . . . public function getUsername(){ return $this->_name; } I'm sure you'll all laugh and say, "That's obvious!" and after I read it, I'll smack myself in the head for missing it, but anyway. :-) Thanks, Ray
×
×
  • Create New...