Made message signing in Cryptography use SHA512 as the message content for... #1
5 changed files with 153 additions and 0 deletions
|
@ -118,6 +118,9 @@
|
||||||
$config->setDefault('registration.otp_required', false);
|
$config->setDefault('registration.otp_required', false);
|
||||||
$config->setDefault('registration.display_name_required', true);
|
$config->setDefault('registration.display_name_required', true);
|
||||||
$config->setDefault('registration.display_picture_required', false);
|
$config->setDefault('registration.display_picture_required', false);
|
||||||
|
$config->setDefault('registration.email_address_required', false);
|
||||||
|
$config->setDefault('registration.phone_number_required', false);
|
||||||
|
$config->setDefault('registration.birthday_required', false);
|
||||||
$config->setDefault('registration.image_captcha_verification_required', true);
|
$config->setDefault('registration.image_captcha_verification_required', true);
|
||||||
|
|
||||||
// Server Policies
|
// Server Policies
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
private bool $otpRequired;
|
private bool $otpRequired;
|
||||||
private bool $displayNameRequired;
|
private bool $displayNameRequired;
|
||||||
private bool $displayPictureRequired;
|
private bool $displayPictureRequired;
|
||||||
|
private bool $emailAddressRequired;
|
||||||
|
private bool $phoneNumberRequired;
|
||||||
|
private bool $birthdayRequired;
|
||||||
private bool $imageCaptchaVerificationRequired;
|
private bool $imageCaptchaVerificationRequired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +50,9 @@
|
||||||
$this->otpRequired = (bool)$data['otp_required'];
|
$this->otpRequired = (bool)$data['otp_required'];
|
||||||
$this->displayNameRequired = (bool)$data['display_name_required'];
|
$this->displayNameRequired = (bool)$data['display_name_required'];
|
||||||
$this->displayPictureRequired = (bool)$data['display_picture_required'];
|
$this->displayPictureRequired = (bool)$data['display_picture_required'];
|
||||||
|
$this->emailAddressRequired = (bool)$data['email_address_required'];
|
||||||
|
$this->phoneNumberRequired = (bool)$data['phone_number_required'];
|
||||||
|
$this->birthdayRequired = (bool)$data['birthday_required'];
|
||||||
$this->imageCaptchaVerificationRequired = (bool)$data['image_captcha_verification_required'];
|
$this->imageCaptchaVerificationRequired = (bool)$data['image_captcha_verification_required'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +196,36 @@
|
||||||
return $this->displayPictureRequired;
|
return $this->displayPictureRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether an email address is required.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if an email address is required, false otherwise.
|
||||||
|
*/
|
||||||
|
public function isEmailAddressRequired(): bool
|
||||||
|
{
|
||||||
|
return $this->emailAddressRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if a phone number is required.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if a phone number is required, false otherwise.
|
||||||
|
*/
|
||||||
|
public function isPhoneNumberRequired(): bool
|
||||||
|
{
|
||||||
|
return $this->phoneNumberRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if a birthday is required.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if a birthday is required, otherwise false.
|
||||||
|
*/
|
||||||
|
public function isBirthdayRequired(): bool
|
||||||
|
{
|
||||||
|
return $this->birthdayRequired;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if image CAPTCHA verification is required.
|
* Determines if image CAPTCHA verification is required.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Socialbox\Classes\StandardMethods;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Socialbox\Abstracts\Method;
|
||||||
|
use Socialbox\Classes\Configuration;
|
||||||
|
use Socialbox\Enums\StandardError;
|
||||||
|
use Socialbox\Exceptions\StandardException;
|
||||||
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
|
use Socialbox\Managers\RegisteredPeerManager;
|
||||||
|
use Socialbox\Objects\ClientRequest;
|
||||||
|
use Socialbox\Objects\RpcRequest;
|
||||||
|
|
||||||
|
class SettingsDeleteBirthday extends Method
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
|
{
|
||||||
|
if(Configuration::getRegistrationConfiguration()->isBirthdayRequired())
|
||||||
|
{
|
||||||
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'A birthday is required for this server');
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegisteredPeerManager::deleteBirthday($request->getPeer());
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
throw new StandardException('Failed to delete birthday ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rpcRequest->produceResponse(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Socialbox\Classes\StandardMethods;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Socialbox\Abstracts\Method;
|
||||||
|
use Socialbox\Classes\Configuration;
|
||||||
|
use Socialbox\Enums\StandardError;
|
||||||
|
use Socialbox\Exceptions\StandardException;
|
||||||
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
|
use Socialbox\Managers\RegisteredPeerManager;
|
||||||
|
use Socialbox\Objects\ClientRequest;
|
||||||
|
use Socialbox\Objects\RpcRequest;
|
||||||
|
|
||||||
|
class SettingsDeleteEmailAddress extends Method
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
|
{
|
||||||
|
if(Configuration::getRegistrationConfiguration()->isEmailAddressRequired())
|
||||||
|
{
|
||||||
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'A email address is required for this server');
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegisteredPeerManager::deleteEmailAddress($request->getPeer());
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
throw new StandardException('Failed to delete email address: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rpcRequest->produceResponse(true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Socialbox\Classes\StandardMethods;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Socialbox\Abstracts\Method;
|
||||||
|
use Socialbox\Classes\Configuration;
|
||||||
|
use Socialbox\Enums\StandardError;
|
||||||
|
use Socialbox\Exceptions\StandardException;
|
||||||
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
|
use Socialbox\Managers\RegisteredPeerManager;
|
||||||
|
use Socialbox\Objects\ClientRequest;
|
||||||
|
use Socialbox\Objects\RpcRequest;
|
||||||
|
|
||||||
|
class SettingsDeletePhoneNumber extends Method
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
|
{
|
||||||
|
if(Configuration::getRegistrationConfiguration()->isPhoneNumberRequired())
|
||||||
|
{
|
||||||
|
return $rpcRequest->produceError(StandardError::FORBIDDEN, 'A phone number is required for this server');
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RegisteredPeerManager::deletePhoneNumber($request->getPeer());
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
throw new StandardException('Failed to delete phone number: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rpcRequest->produceResponse(true);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue