Added the method SettingsSetBirthday
This commit is contained in:
parent
c0de6ce006
commit
585ff46810
2 changed files with 23 additions and 9 deletions
|
@ -21,27 +21,41 @@
|
||||||
*/
|
*/
|
||||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||||
{
|
{
|
||||||
if(!$rpcRequest->containsParameter('email_address'))
|
if(!$rpcRequest->containsParameter('month'))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Missing 'email_address' parameter");
|
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Missing 'month' parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Validator::validateEmailAddress($rpcRequest->getParameter('email_address')))
|
if(!$rpcRequest->containsParameter('day'))
|
||||||
{
|
{
|
||||||
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Invalid 'email_address' parameter, must be a valid email address");
|
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Missing 'day' parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$rpcRequest->containsParameter('year'))
|
||||||
|
{
|
||||||
|
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Missing 'year' parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
$month = $rpcRequest->getParameter('month');
|
||||||
|
$day = $rpcRequest->getParameter('day');
|
||||||
|
$year = $rpcRequest->getParameter('year');
|
||||||
|
|
||||||
|
if(!Validator::validateDate($month, $day, $year))
|
||||||
|
{
|
||||||
|
return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, "Invalid date provided, must be a valid gregorian calender date.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Set the password
|
// Set the password
|
||||||
RegisteredPeerManager::updateEmailAddress($request->getPeer(), $rpcRequest->getParameter('email_address'));
|
RegisteredPeerManager::updateBirthday($request->getPeer(), $month, $day, $year);
|
||||||
|
|
||||||
// Check & update the session flow
|
// Check & update the session flow
|
||||||
SessionManager::updateFlow($request->getSession(), [SessionFlags::SET_EMAIL]);
|
SessionManager::updateFlow($request->getSession(), [SessionFlags::SET_BIRTHDAY]);
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
throw new StandardException('Failed to set email address due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
throw new StandardException('Failed to set birthday due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rpcRequest->produceResponse(true);
|
return $rpcRequest->produceResponse(true);
|
||||||
|
|
|
@ -676,14 +676,14 @@
|
||||||
* Sets the birthday of a registered peer record based on the provided date components.
|
* Sets the birthday of a registered peer record based on the provided date components.
|
||||||
*
|
*
|
||||||
* @param string|RegisteredPeerRecord $peer The unique identifier of the peer or an instance of RegisteredPeerRecord.
|
* @param string|RegisteredPeerRecord $peer The unique identifier of the peer or an instance of RegisteredPeerRecord.
|
||||||
* @param int $year The year component of the birthday.
|
|
||||||
* @param int $month The month component of the birthday.
|
* @param int $month The month component of the birthday.
|
||||||
* @param int $day The day component of the birthday.
|
* @param int $day The day component of the birthday.
|
||||||
|
* @param int $year The year component of the birthday.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws InvalidArgumentException If the peer is external or the provided date is invalid.
|
* @throws InvalidArgumentException If the peer is external or the provided date is invalid.
|
||||||
* @throws DatabaseOperationException If there is an error during the database operation.
|
* @throws DatabaseOperationException If there is an error during the database operation.
|
||||||
*/
|
*/
|
||||||
public static function setBirthday(string|RegisteredPeerRecord $peer, int $year, int $month, int $day): void
|
public static function updateBirthday(string|RegisteredPeerRecord $peer, int $month, int $day, int $year): void
|
||||||
{
|
{
|
||||||
if(is_string($peer))
|
if(is_string($peer))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue