Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
EmailService Class Reference
Inheritance diagram for EmailService:
EAuthServiceBase IAuthService IUserFields IAuthService

Public Member Functions

 authenticate ()
 redirect ($url=null)
 cancel ($url=null)
 getEmail ()
 getName ()
 getError ()
- Public Member Functions inherited from EAuthServiceBase
 __get ($name)
 __isset ($name)
 init ($component, $options=array())
 getServiceName ()
 getServiceTitle ()
 getServiceType ()
 getJsArguments ()
 setComponent ($component)
 getComponent ()
 setRedirectUrl ($url)
 getRedirectUrl ()
 setCancelUrl ($url)
 getCancelUrl ()
 getIsAuthenticated ()
 getId ()
 getAttributes ()
 getAttribute ($key, $default=null)
 hasAttribute ($key)
 getItem ()
 getItemAttributes ()
- Public Member Functions inherited from IAuthService
 cancel ()

Public Attributes

const ERROR_NONE = 0
const ERROR_AUTH_FAILED = 1
const ERROR_ACTIVATION_MAIL_SENT = 2
const ERROR_ACTIVATION_MAIL_FAILED = 3
 $username
 $password
 $email
 $errorCode
 $user = null

Protected Attributes

 $name = 'email'
 $title = 'E-mail'
 $type = 'email'
- Protected Attributes inherited from EAuthServiceBase
 $name
 $title
 $type
 $jsArguments = array()
 $attributes = array()
 $authenticated = false

Additional Inherited Members

- Protected Member Functions inherited from EAuthServiceBase
 makeRequest ($url, $options=array(), $parseJson=true)
 initRequest ($url, $options=array())
 parseJson ($response)
 fetchJsonError ($json)
 getStateKeyPrefix ()
 setState ($key, $value, $defaultValue=null)
 hasState ($key)
 getState ($key, $defaultValue=null)
 fetchAttributes ()
 _fetchAttributes ()

Detailed Description

Definition at line 5 of file EmailService.php.

Member Function Documentation

string password field put here password with which you want to EmailService::authenticate ( )

This function simply tries to authenticate auth identity (see docs about user authenticating behaviour)

Returns
bool is user identity authenticated or authentication failed

Reimplemented from EAuthServiceBase.

Definition at line 59 of file EmailService.php.

References ERROR_AUTH_FAILED, ERROR_NONE, and User\model().

{
$email = $this->email;
$username = $this->username;
$password = $this->password;
$password_hash = Yii::app()->getModule('user')->encrypting($password);
$this->authenticated = false;
if ($this->authField == 'email') {
$user = User::model()->findByAttributes(array('email' => $email, 'password' => $password_hash));
} else if ($this->authField == 'username') {
$user = User::model()->findByAttributes(array('username' => $username, 'password' => $password_hash));
} else
return false;
if ($user) {
$this->attributes['id'] = $this->attributes['email'] = $this->attributes['displayId'] = $username;
$this->authenticated = true;
$this->errorCode = self::ERROR_NONE;
} else {
$this->errorCode = self::ERROR_AUTH_FAILED;
}
Yii::log("EmailService auth resulted with code $this->errorCode.", CLogger::LEVEL_INFO);
return $this->authenticated;
}
EmailService::cancel (   $url = null)

Simply redirects user to the specified url (if not specified, cancelUrl property will be used instead)

We have to override this function, because email authentication doesn't require popup.

Parameters
string$url

Reimplemented from EAuthServiceBase.

Definition at line 102 of file EmailService.php.

References EAuthServiceBase\getCancelUrl().

{
Yii::app()->request->redirect(isset($url) ? $url : $this->getCancelUrl(), false);
}
EmailService::redirect (   $url = null)

Simply redirects user to the specified url (if not specified, redirectUrl property will be used instead)

We have to override this function, because email authentication doesn't require popup.

Parameters
string$url

Reimplemented from EAuthServiceBase.

Definition at line 91 of file EmailService.php.

References EAuthServiceBase\getRedirectUrl().

{
Yii::app()->request->redirect(isset($url) ? $url : $this->getRedirectUrl(), true);
}

Member Data Documentation

const EmailService::ERROR_ACTIVATION_MAIL_FAILED = 3

Error occured while trying to send activation mail.

Definition at line 23 of file EmailService.php.

const EmailService::ERROR_ACTIVATION_MAIL_SENT = 2

No errors occured. Activation mail to user was sent and user will be registered as soon as he will click the activation url in the email message body.

Definition at line 19 of file EmailService.php.

const EmailService::ERROR_AUTH_FAILED = 1

Failed to authenticate authentication identity (email-password mismatch).

Definition at line 14 of file EmailService.php.

Referenced by authenticate().

const EmailService::ERROR_NONE = 0

Everything is OK.

Definition at line 10 of file EmailService.php.

Referenced by authenticate().


The documentation for this class was generated from the following file: