<?php
namespace App\Document\ExternalAPI;
use App\Document\Security\Role;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document(repositoryClass="App\Repository\ExternalAPI\APIUserRepository")
* @MongoDBUnique(fields="username")
*/
class APIUser implements UserInterface, \Serializable
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\Field(type="string")
*/
protected $username;
/**
* @MongoDB\Field(type="string")
*/
protected $password;
/**
* @MongoDB\Field(type="string")
*/
protected $fullName;
/**
* @MongoDB\Field(type="string")
*/
protected $nic;
/**
* @MongoDB\Field(type="string")
*/
protected $email;
/**
* @MongoDB\ReferenceOne(targetDocument="App\Document\ExternalAPI\APIRole")
*/
protected $role;
/**
* @MongoDB\Field(type="string")
*/
protected $roleCode;
/**
* @MongoDB\Field(type="string")
*/
protected $primaryContact;
/**
* @MongoDB\Field(type="string")
* @Assert\Blank()
*/
protected $salt;
/**
* @MongoDB\Field(type="boolean")
*/
protected $isActive;
/**
* @MongoDB\Field(type="boolean")
*/
protected $status;
/**
* @MongoDB\Field(type="date")
*/
protected $lastLoginAt;
/**
* @MongoDB\Field(type="date")
*/
protected $createdAt;
/**
* @MongoDB\Field(type="date")
*/
protected $updatedAt;
/**
* @MongoDB\ReferenceOne(targetDocument="App\Document\Security\User",cascade={"persist"})
*/
protected $updatedBy;
/**
* @MongoDB\ReferenceOne(targetDocument="App\Document\Common\LegalEntity")
*/
protected $legalEntity;
/**
* @MongoDB\Field(type="string")
*/
protected $legalEntityMeta;
/**
* @MongoDB\Field(type="boolean")
*/
protected $isSignIn;
/**
* @MongoDB\Field(type="boolean")
*/
protected $isSingleLogin;
/**
* @MongoDB\ReferenceOne(targetDocument="App\Document\Common\LegalEntity")
*/
protected $activeAccessToken;
public function __construct()
{
$this->isSingleLogin = false;
$this->isActive = true;
$this->status = true;
$this->isSignIn = false;
$this->createdAt = new \DateTime('now', new \DateTimeZone('Asia/Colombo'));
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getUsername()
{
return $this->username;
}
/**
* @param mixed $username
*/
public function setUsername($username): void
{
$this->username = $username;
}
/**
* @return mixed
*/
public function getPassword()
{
return $this->password;
}
/**
* @param mixed $password
*/
public function setPassword($password): void
{
$this->password = $password;
}
/**
* @return mixed
*/
public function getFullName()
{
return $this->fullName;
}
/**
* @param mixed $fullName
*/
public function setFullName($fullName): void
{
$this->fullName = $fullName;
}
/**
* @return mixed
*/
public function getNic()
{
return $this->nic;
}
/**
* @param mixed $nic
*/
public function setNic($nic): void
{
$this->nic = $nic;
}
/**
* @return mixed
*/
public function getEmail()
{
return $this->email;
}
/**
* @param mixed $email
*/
public function setEmail($email): void
{
$this->email = $email;
}
/**
* @return mixed
*/
public function getPrimaryContact()
{
return $this->primaryContact;
}
/**
* @param mixed $primaryContact
*/
public function setPrimaryContact($primaryContact): void
{
$this->primaryContact = $primaryContact;
}
/**
* @return mixed
*/
public function getSalt()
{
return $this->salt;
}
/**
* @param mixed $salt
*/
public function setSalt($salt): void
{
$this->salt = $salt;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->isActive;
}
/**
* @param bool $isActive
*/
public function setIsActive(bool $isActive): void
{
$this->isActive = $isActive;
}
/**
* @return bool
*/
public function isStatus(): bool
{
return $this->status;
}
/**
* @param bool $status
*/
public function setStatus(bool $status): void
{
$this->status = $status;
}
/**
* @return mixed
*/
public function getLastLoginAt()
{
return $this->lastLoginAt;
}
/**
* @param mixed $lastLoginAt
*/
public function setLastLoginAt($lastLoginAt): void
{
$this->lastLoginAt = $lastLoginAt;
}
/**
* @return mixed
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @param mixed $createdAt
*/
public function setCreatedAt($createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* @return mixed
*/
public function getUpdatedBy()
{
return $this->updatedBy;
}
/**
* @param mixed $updatedBy
*/
public function setUpdatedBy($updatedBy): void
{
$this->updatedBy = $updatedBy;
}
/**
* @return mixed
*/
public function getLegalEntity()
{
return $this->legalEntity;
}
/**
* @param mixed $legalEntity
*/
public function setLegalEntity($legalEntity): void
{
$this->legalEntity = $legalEntity;
}
/**
* @return mixed
*/
public function getLegalEntityMeta()
{
return $this->legalEntityMeta;
}
/**
* @param mixed $legalEntityMeta
*/
public function setLegalEntityMeta($legalEntityMeta): void
{
$this->legalEntityMeta = $legalEntityMeta;
}
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
));
}
public function unserialize($data)
{
list (
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($data, array('allowed_classes' => true));
}
/**
* @return mixed
*/
public function getRole():APIRole
{
return $this->role;
}
/**
* @param mixed $role
*/
public function setRole($role): void
{
$this->role = $role;
}
public function getRoles()
{
return [$this->getRole()->getCode()];
}
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
/**
* @return mixed
*/
public function getRoleCode()
{
return $this->roleCode;
}
/**
* @param mixed $roleCode
*/
public function setRoleCode($roleCode): void
{
$this->roleCode = $roleCode;
}
public function getIsSignIn(): ?bool
{
return $this->isSignIn;
}
public function setIsSignIn(bool $isSignIn): void
{
$this->isSignIn = $isSignIn;
}
public function getIsSingleLogin(): ?bool
{
return $this->isSingleLogin;
}
public function setIsSingleLogin(bool $isSingleLogin): void
{
$this->isSingleLogin = $isSingleLogin;
}
/**
* @return mixed
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @param mixed $updatedAt
*/
public function setUpdatedAt($updatedAt): void
{
$this->updatedAt = $updatedAt;
}
/**
* @return mixed
*/
public function getActiveAccessToken()
{
return $this->activeAccessToken;
}
/**
* @param mixed $activeAccessToken
*/
public function setActiveAccessToken($activeAccessToken): void
{
$this->activeAccessToken = $activeAccessToken;
}
}