Yii Framework Forum: Blog tutorial problem: UserIdentity class - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Blog tutorial problem: UserIdentity class problem running blog tutorial code - authenticating the user Rate Topic: -----

#1 User is offline   ybrunet 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 25-October 11

Posted 25 October 2011 - 11:16 AM

I was following the blog tutorial on the yii tutorial site.
In "Authenticating User" section, I cannot login using UserIdentity code
posted in the tutorial. I get a blank screen.
I'm probably getting a fatal error somewhere but I don't see the error in the apache log file.

When I step the code using the xdebug debugger, the $user object does not seemed to be constructed correctly. I can not step past the line:
if($user===null)

When I inspect $user object, I only see the classname with no other attributes.

Below is the UserIdentity class I use (from the blog tutorial).
Does anyone know the cause?


class UserIdentity extends CUserIdentity
{
private $_id;

public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find('LOWER(username)=?',array($username));

if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else
if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}

public function getId()
{
return $this->_id;
}
}
0

#2 User is offline   ybrunet 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 25-October 11

Posted 25 October 2011 - 01:11 PM

I found where the fatal error was. It was in User class (had undefined function). UserIdentity class was just fine.
0

#3 User is offline   ajzip 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-December 13

Posted 23 January 2014 - 09:56 PM

Can you be more specific regarding the fix? I'm having the same problem but don't know what you mean by "had undefined function" in User class.

Thanks in advance for the help.
0

#4 User is offline   MontyEdwards 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 05-February 14

Posted 05 February 2014 - 07:36 AM

View Postajzip, on 23 January 2014 - 09:56 PM, said:

Can you be more specific regarding the fix? I'm having the same problem but don't know what you mean by "had undefined function" in User class.

Thanks in advance for the help.


I am also having a problem cannot login as user demo get the following error.
include(CPasswordHelper.php): failed to open stream: No such file or directory
0

#5 User is offline   i.am.vj 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 07-January 14

Posted 05 February 2014 - 01:54 PM

@MontyEdwards: your basePath in the main.php config file and ensure that it is set correctly. The error you are getting states that you are using CPasswordHelper:: but that the autoloader cannot finder the class file to load it.

@ajzip: What does your application.php log file say? Check that file for any exceptions that are being generated and report back what you find.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users