<?php
namespace Claromentis\People\Repository;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] ?: array()) + array("_539cf4259a149ca9dbb739b2" . "cdb7c608" => base64_decode("ZW1haW" . "xfYWRk" . "cmVzcw" . "=="), "_49ee1e842dca787e7c39f0" . "2341effb25" => base64_decode("ZXhw" . "aXJ5"), "_bb152d3d0f3a7af77c042d" . "ab184b9545" => base64_decode("PQ=" . "="), "_cf033e4" . "c9431fde" . "2bbd6618" . "86c59fdd" . "3" => base64_decode("cmVj" . "b3Zl" . "cnlf" . "a2V5"), "_5fa693ebe935ee7dcd0ae554bb45" . "625b" => base64_decode("PA=" . "="));
use Analogue\ORM\Mappable;
use Claromentis\Core\ORM\Mapper;
use Claromentis\People\Entity\Map\PasswordRecoveryMap;
use Claromentis\People\Entity\PasswordRecovery;
use CryptUtils;




class PasswordRecoveryRepository extends Repository
{
    private int $recovery_link_ttl;
    public function __construct(Mapper $_dabd1eb8030f2c29327a192cddfd85a9, int $_90d3a1490ca601e77202002edc432597, PasswordRecoveryMap $_a9930332dbb35bfb835571676fb76572 = null)
    {
        parent::__construct($_dabd1eb8030f2c29327a192cddfd85a9, $_a9930332dbb35bfb835571676fb76572);
        $this->recovery_link_ttl = $_90d3a1490ca601e77202002edc432597;
    }
    
    
    
    
    
    
    
    
    public function findByKey(string $key) : ?PasswordRecovery
    {
        
        
        
        
        $_baef853fe4827ca40530d2e18f8c1954 = $this->mapper->where($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_cf033e4c9431fde2bbd6618" . "86c59fdd3"], $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_bb152d3d0f" . "3a7af77c042" . "dab184b9545"], $key)->first();
        return $_baef853fe4827ca40530d2e18f8c1954;
    }
    
    
    
    
    public function removeExpiredKeys() : void
    {
        $_d230962d9a57dc6ba2b774d9ba3bb81e = new \Date();
        $_dc766987565ddc79324667d95a417530 = $this->mapper->where($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_49ee1e8" . "42dca787" . "e7c39f02" . "341effb2" . "5"], $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_5fa693ebe935e" . "e7dcd0ae554bb4" . "5625b"], $_d230962d9a57dc6ba2b774d9ba3bb81e->getDate(DATE_FORMAT_TIMESTAMP))->get();
        foreach ($_dc766987565ddc79324667d95a417530 as $_6c3d3c129145e7ed86d47004c40d5707) {
            $this->removeKey($_6c3d3c129145e7ed86d47004c40d5707);
        }
    }
    
    
    
    
    public function removeKey(PasswordRecovery $_cf033e4c9431fde2bbd661886c59fdd3) : void
    {
        $this->mapper->delete($_cf033e4c9431fde2bbd661886c59fdd3);
    }
    public function createAndStoreFromEmail(string $_539cf4259a149ca9dbb739b2cdb7c608) : Mappable
    {
        $_49ee1e842dca787e7c39f02341effb25 = new \Date();
        $_49ee1e842dca787e7c39f02341effb25->addDays($this->recovery_link_ttl);
        $_baef853fe4827ca40530d2e18f8c1954 = $this->newInstance();
        $_baef853fe4827ca40530d2e18f8c1954->setEntityAttribute($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_cf033e4c9431f" . "de2bbd661886c5" . "9fdd3"], CryptUtils::GetRandomString());
        $_baef853fe4827ca40530d2e18f8c1954->setEntityAttribute($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_49ee1e842dca787e7c39f023" . "41effb25"], $_49ee1e842dca787e7c39f02341effb25->getDate(DATE_FORMAT_TIMESTAMP));
        $_baef853fe4827ca40530d2e18f8c1954->setEntityAttribute($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_539cf4259a149ca9dbb739" . "b2cdb7c608"], $_539cf4259a149ca9dbb739b2cdb7c608);
        $this->store($_baef853fe4827ca40530d2e18f8c1954);
        return $_baef853fe4827ca40530d2e18f8c1954;
    }
}