Elgg\Database\UsersTable::validateInviteCode PHP Method

validateInviteCode() public method

Validate a user's invite code
See also: generateInviteCode
public validateInviteCode ( string $username, string $code ) : boolean
$username string The username
$code string The invite code
return boolean
    public function validateInviteCode($username, $code)
    {
        // validate the format of the token created by ->generateInviteCode()
        if (!preg_match('~^(\\d+)\\.([a-zA-Z0-9\\-_]+)$~', $code, $m)) {
            return false;
        }
        $time = $m[1];
        $mac = $m[2];
        return _elgg_services()->crypto->getHmac([(int) $time, $username])->matchesToken($mac);
    }