Files
openstackid/app/models/Member.php
Sebastian Marcet 0e93b131a0 Fix on Email Verification
* Now users only could be logged in only if they verified they email addresss
* added link on login page to resend email verification
* fixed some styles to be more mobile friendly

Change-Id: I55afd401ff69404414c95dc267e9fbdf4fe26a70
2016-03-22 18:02:24 -03:00

62 lines
1.3 KiB
PHP

<?php
use auth\AuthHelper;
use utils\model\BaseModelEloquent;
/**
* Class Member
*/
class Member extends BaseModelEloquent
{
protected $primaryKey ='ID';
protected $table = 'Member';
//external os members db (SS)
protected $connection = 'os_members';
//no timestamps
public $timestamps = false;
public function checkPassword($password)
{
$hash = AuthHelper::encrypt_password($password, $this->Salt, $this->PasswordEncryption);
$res = AuthHelper::compare($this->Password, $hash , $this->PasswordEncryption);
return $res;
}
public function groups()
{
return $this->belongsToMany('Group', 'Group_Members', 'MemberID', 'GroupID');
}
/**
* @return bool
*/
public function canLogin()
{
return $this->isEmailVerified() && $this->isActive();
}
public function isActive(){
$attr = $this->getAttributes();
if(isset($attr['Active']))
{
return (bool)$attr['Active'];
}
return false;
}
/**
* @return bool
*/
public function isEmailVerified()
{
$attr = $this->getAttributes();
if(isset($attr['EmailVerified']))
{
return (bool)$attr['EmailVerified'];
}
return false;
}
}