Programming Language PHP

Namespace Elabftw\Models

Class ExistingUser

Total Examples 1

1 code examples of PHP Elabftw\Models\ExistingUser extracted from open source projects

Was this example useful?
0
                                                    public function validate(string $key): Users
    {
        $decryptedKey = Crypto::decrypt($key, Key::loadFromAsciiSafeString($this->secretKey));
        $exploded = explode(self::SEPARATOR, $decryptedKey);
        if (count($exploded) !== 2) {
            throw new IllegalActionException('Something is wrong with the number of exploded values during password reset.');
        }
        $email = $exploded[0];
        $deadline = $exploded[1];

        if ($deadline < $this->now) {
            throw new ImproperActionException(sprintf(_('This link has expired! Password reset links are only valid for %s minutes.'), self::LINK_LIFETIME));
        }

        // if the key is correct, we now have an ExistingUser here
        return ExistingUser::fromEmail($email);
    }
                                            
ExistingUser's Other Methods
ExistingUser's Other Methods