Skip to content
Snippets Groups Projects
Commit 0cad6c22 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #16992 TIME 0:30 Set sms and email content in admin otp

parent 3623ba2c
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,7 @@ CREATE TABLE external_signatory_book
type character varying(128) NOT NULL,
connection_data jsonb DEFAULT '{}',
otp_code jsonb DEFAULT '{}',
message_content jsonb DEFAULT '{}',
CONSTRAINT external_signatory_book_pkey PRIMARY KEY (id)
)
WITH (OIDS=FALSE);
......
......@@ -52,6 +52,9 @@ class ExternalSignatoryBookController
$connector['securityModes'] = json_decode($connector['otp_code'], true);
unset($connector['otp_code']);
$connector['message'] = json_decode($connector['message_content'], true);
unset($connector['message_content']);
$connectionData = json_decode($connector['connection_data'], true);
$connector['apiUri'] = $connectionData['apiUri'];
$connector['apiKey'] = $connectionData['apiKey'];
......@@ -91,6 +94,12 @@ class ExternalSignatoryBookController
if (empty($body['apiUri']) || empty($body['apiKey'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body apiUri or apiKey is empty']);
}
if (in_array('sms', $body['securityModes']) && empty($body['message']['sms'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body message sms must be set']);
}
if (in_array('email', $body['securityModes']) && empty($body['message']['email'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body message email must be set']);
}
}
$connectionData = ['apiUri' => $body['apiUri'], 'apiKey' => $body['apiKey']];
......@@ -100,6 +109,7 @@ class ExternalSignatoryBookController
'type' => $body['type'],
'connection_data' => json_encode($connectionData),
'otp_code' => json_encode($body['securityModes']),
'message_content' => json_encode($body['message']),
]);
HistoryController::add([
......@@ -146,6 +156,12 @@ class ExternalSignatoryBookController
if (empty($body['apiUri']) || empty($body['apiKey'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body apiUri or apiKey is empty']);
}
if (in_array('sms', $body['securityModes']) && empty($body['message']['sms'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body message sms must be set']);
}
if (in_array('email', $body['securityModes']) && empty($body['message']['email'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body message email must be set']);
}
}
$connectionData = ['apiUri' => $body['apiUri'], 'apiKey' => $body['apiKey']];
......@@ -160,7 +176,8 @@ class ExternalSignatoryBookController
'label' => $body['label'],
'type' => $body['type'],
'connection_data' => json_encode($connectionData),
'otp_code' => json_encode($body['securityModes'])
'otp_code' => json_encode($body['securityModes']),
'message_content' => json_encode($body['message']),
],
'where' => ['id = ?'],
'data' => [$aArgs['id']]
......
......@@ -69,6 +69,7 @@ class ExternalSignatoryBookModel
'type' => $aArgs['type'],
'connection_data' => $aArgs['connection_data'],
'otp_code' => $aArgs['otp_code'],
'message_content' => $aArgs['message_content'],
]
]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment