add validation process
This commit is contained in:
parent
79887ee7e6
commit
cee3aefec5
9 changed files with 263 additions and 34 deletions
43
css/style.css
Normal file
43
css/style.css
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
/* Reset the table styles */
|
||||||
|
table.wisski-cloud-account-manager-table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Style for table headers */
|
||||||
|
table.wisski-cloud-account-manager-table th {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate row background color */
|
||||||
|
table.wisski-cloud-account-manager-table tr:nth-child(even) {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Style for table cells */
|
||||||
|
table.wisski-cloud-account-manager-table td {
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #dddddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Center-align certain cells */
|
||||||
|
table.wisski-cloud-account-manager-table td.valid,
|
||||||
|
table.wisski-cloud-account-manager-table td.provisioned {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wisski-cloud-account-manager-success {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
.wisski-cloud-account-manager-warning {
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
|
.wisski-cloud-account-manager-error {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wisski-cloud-account-manager-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
@ -3,23 +3,79 @@
|
||||||
namespace Drupal\wisski_cloud_account_manager\Controller;
|
namespace Drupal\wisski_cloud_account_manager\Controller;
|
||||||
|
|
||||||
use Drupal\Core\Controller\ControllerBase;
|
use Drupal\Core\Controller\ControllerBase;
|
||||||
|
use Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Wisski Cloud account manager info controller.
|
* The Wisski Cloud account manager info controller.
|
||||||
*/
|
*/
|
||||||
class WisskiCloudAccountManagerController extends ControllerBase {
|
class WisskiCloudAccountManagerController extends ControllerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions
|
||||||
|
* The WissKi Cloud account manager daemon API actions service.
|
||||||
|
*/
|
||||||
|
protected WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param \Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions
|
||||||
|
* The WissKi Cloud account manager daemon API actions service.
|
||||||
|
*/
|
||||||
|
public function __construct(WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions) {
|
||||||
|
$this->wisskiCloudAccountManagerDaemonApiActions = $wisskiCloudAccountManagerDaemonApiActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the reachable variables from services.
|
||||||
|
*
|
||||||
|
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||||
|
* The class container.
|
||||||
|
*/
|
||||||
|
public static function create(ContainerInterface $container) {
|
||||||
|
return new static(
|
||||||
|
$container->get('wisski_cloud_account_manager.daemon_api.actions'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Info page for terms and conditions.
|
* Info page for terms and conditions.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* The page build array.
|
* The page build array.
|
||||||
*/
|
*/
|
||||||
public function termsAndConditions(): array {
|
public function termsAndConditionsPage(): array {
|
||||||
$build = [
|
$build = [
|
||||||
'#markup' => $this->t('Hello World!'),
|
'#markup' => $this->t('Hello World!'),
|
||||||
];
|
];
|
||||||
return $build;
|
return $build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page to check the validation and provision status.
|
||||||
|
*
|
||||||
|
* @param string $validationCode
|
||||||
|
* The token to check the status for.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* The page build array.
|
||||||
|
*/
|
||||||
|
public function validationPage(string $validationCode): array {
|
||||||
|
$validationResponse = $this->wisskiCloudAccountManagerDaemonApiActions->validateAccount($validationCode);
|
||||||
|
|
||||||
|
$responseContents = json_decode($validationResponse->getBody()
|
||||||
|
->getContents(), TRUE);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'#theme' => 'wisski_cloud_account_manager_validation_page',
|
||||||
|
'#responseContents' => $responseContents,
|
||||||
|
'#attached' => [
|
||||||
|
'library' => [
|
||||||
|
'wisski_cloud_account_manager/wisski_cloud_account_manager',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\wisski_cloud_account_manager\Form;
|
namespace Drupal\wisski_cloud_account_manager\Form;
|
||||||
|
|
||||||
|
use Drupal\Component\Utility\EmailValidatorInterface;
|
||||||
use Drupal\Core\Form\FormBase;
|
use Drupal\Core\Form\FormBase;
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
use Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions;
|
use Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions;
|
||||||
|
|
@ -18,10 +19,16 @@ class WisskiCloudAccountManagerCreateForm extends FormBase {
|
||||||
*/
|
*/
|
||||||
protected WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions;
|
protected WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Drupal\Component\Utility\EmailValidatorInterface
|
||||||
|
* The email validator service.
|
||||||
|
*/
|
||||||
|
private EmailValidatorInterface $emailValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getFormId() {
|
public function getFormId(): string {
|
||||||
return 'wisski_cloud_account_manager_create';
|
return 'wisski_cloud_account_manager_create';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,9 +37,12 @@ class WisskiCloudAccountManagerCreateForm extends FormBase {
|
||||||
*
|
*
|
||||||
* @param \Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions
|
* @param \Drupal\wisski_cloud_account_manager\WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions
|
||||||
* The WissKi Cloud account manager daemon API actions service.
|
* The WissKi Cloud account manager daemon API actions service.
|
||||||
|
* @param \Drupal\Component\Utility\EmailValidatorInterface $emailValidator
|
||||||
|
* The email validator service.
|
||||||
*/
|
*/
|
||||||
public function __construct(WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions) {
|
public function __construct(WisskiCloudAccountManagerDaemonApiActions $wisskiCloudAccountManagerDaemonApiActions, EmailValidatorInterface $emailValidator) {
|
||||||
$this->wisskiCloudAccountManagerDaemonApiActions = $wisskiCloudAccountManagerDaemonApiActions;
|
$this->wisskiCloudAccountManagerDaemonApiActions = $wisskiCloudAccountManagerDaemonApiActions;
|
||||||
|
$this->emailValidator = $emailValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,6 +54,7 @@ class WisskiCloudAccountManagerCreateForm extends FormBase {
|
||||||
public static function create(ContainerInterface $container) {
|
public static function create(ContainerInterface $container) {
|
||||||
return new static(
|
return new static(
|
||||||
$container->get('wisski_cloud_account_manager.daemon_api.actions'),
|
$container->get('wisski_cloud_account_manager.daemon_api.actions'),
|
||||||
|
$container->get('email.validator'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,20 +137,20 @@ class WisskiCloudAccountManagerCreateForm extends FormBase {
|
||||||
|
|
||||||
$response = $this->wisskiCloudAccountManagerDaemonApiActions->checkAccountData($dataToCheck);
|
$response = $this->wisskiCloudAccountManagerDaemonApiActions->checkAccountData($dataToCheck);
|
||||||
|
|
||||||
if ($response['accountData']['userWithUsername']) {
|
if ($response['accountData']['accountWithUsername']) {
|
||||||
$form_state->setErrorByName('username', $this->t('The username "@username" is already in use.', ['@username' => $dataToCheck['username']]));
|
$form_state->setErrorByName('username', $this->t('The username "@username" is already in use.', ['@username' => $dataToCheck['username']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response['accountData']['userWithEmail']) {
|
if ($response['accountData']['accountWithEmail']) {
|
||||||
$form_state->setErrorByName('email', $this->t('The email "@email" is already in use.', ['@email' => $dataToCheck['email']]));
|
$form_state->setErrorByName('email', $this->t('The email "@email" is already in use.', ['@email' => $dataToCheck['email']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response['accountData']['userWithSubdomain']) {
|
if ($response['accountData']['accountWithSubdomain']) {
|
||||||
$form_state->setErrorByName('subdomain', $this->t('The subdomain "@subdomain" is already in use.', ['@subdomain' => $dataToCheck['subdomain']]));
|
$form_state->setErrorByName('subdomain', $this->t('The subdomain "@subdomain" is already in use.', ['@subdomain' => $dataToCheck['subdomain']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if email is in valid form.
|
// Check if email is in valid form.
|
||||||
if (!\Drupal::service('email.validator')->isValid($dataToCheck['email'])) {
|
if (!$this->emailValidator->isValid($dataToCheck['email'])) {
|
||||||
$form_state->setErrorByName('email', $this->t('Email not in valid form, i.e. "name@example.com".'));
|
$form_state->setErrorByName('email', $this->t('Email not in valid form, i.e. "name@example.com".'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,13 +171,13 @@ class WisskiCloudAccountManagerCreateForm extends FormBase {
|
||||||
|
|
||||||
$accountResponse = $this->wisskiCloudAccountManagerDaemonApiActions->addAccount($account);
|
$accountResponse = $this->wisskiCloudAccountManagerDaemonApiActions->addAccount($account);
|
||||||
dpm($accountResponse, 'accountResponse');
|
dpm($accountResponse, 'accountResponse');
|
||||||
$this->wisskiCloudAccountManagerDaemonApiActions->sendValidationEmail($accountResponse['user']['email'], $accountResponse['user']['validationCode']);
|
$this->wisskiCloudAccountManagerDaemonApiActions->sendValidationEmail($accountResponse['account']['email'], $accountResponse['account']['validationCode']);
|
||||||
|
|
||||||
\Drupal::messenger()
|
$this->messenger()
|
||||||
->addMessage($this->t('The account data has been successfully saved, please check your email for validation!'));
|
->addMessage($this->t('The account data has been successfully saved, please check your email for validation!'));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex) {
|
catch (\Exception $ex) {
|
||||||
\Drupal::logger('wisski_cloud_account_manager')->error($ex->getMessage());
|
$this->logger('wisski_cloud_account_manager')->error($ex->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,18 +42,25 @@ class WisskiCloudAccountManagerSettingsForm extends ConfigFormBase {
|
||||||
'#default_value' => $config->get('daemonUrl'),
|
'#default_value' => $config->get('daemonUrl'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$form['userPostUrlPath'] = [
|
$form['accountPostUrlPath'] = [
|
||||||
'#type' => 'url',
|
'#type' => 'url',
|
||||||
'#title' => $this->t('POST URL path'),
|
'#title' => $this->t('POST URL path'),
|
||||||
'#description' => $this->t('Provide the path to the POST endpoint, i. e. "/user"'),
|
'#description' => $this->t('Provide the path to the POST endpoint, i. e. "/account"'),
|
||||||
'#default_value' => $config->get('userPostUrlPath'),
|
'#default_value' => $config->get('accountPostUrlPath'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$form['userFilterByData'] = [
|
$form['accountFilterByData'] = [
|
||||||
'#type' => 'url',
|
'#type' => 'url',
|
||||||
'#title' => $this->t('Filter by Data URL path'),
|
'#title' => $this->t('Filter by Data URL path'),
|
||||||
'#description' => $this->t('Provide the path to the Get user by data endpoint, i. e. "/user/by_data"'),
|
'#description' => $this->t('Provide the path to the Get account by data endpoint, i. e. "/account/by_data"'),
|
||||||
'#default_value' => $config->get('userFilterByData'),
|
'#default_value' => $config->get('accountFilterByData'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$form['accountValidation'] = [
|
||||||
|
'#type' => 'url',
|
||||||
|
'#title' => $this->t('User Validation URL path'),
|
||||||
|
'#description' => $this->t('Provide the path to the account validation PUT endpoint, i. e. "/account/validation"'),
|
||||||
|
'#default_value' => $config->get('accountValidation'),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
|
|
@ -66,8 +73,10 @@ class WisskiCloudAccountManagerSettingsForm extends ConfigFormBase {
|
||||||
$config = $this->config('wisski_cloud_account_manager.settings');
|
$config = $this->config('wisski_cloud_account_manager.settings');
|
||||||
|
|
||||||
$config->set('daemonURL', $form_state->getValue('daemonURL'))
|
$config->set('daemonURL', $form_state->getValue('daemonURL'))
|
||||||
->set('userPostUrlPath', $form_state->getValue('userPostUrlPath'))
|
->set('accountPostUrlPath', $form_state->getValue('accountPostUrlPath'))
|
||||||
->set('userFilterByData', $form_state->getValue('userFilterByData'))
|
->set('accountFilterByData', $form_state->getValue('accountFilterByData'))
|
||||||
|
->set('accountProvisionAndValidationCheck', $form_state->getValue('accountProvisionAndValidationCheck'))
|
||||||
|
->set('accountValidation', $form_state->getValue('accountValidation'))
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
parent::submitForm($form, $form_state);
|
parent::submitForm($form, $form_state);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use Drupal\Core\Messenger\MessengerInterface;
|
||||||
use Drupal\Core\Render\Markup;
|
use Drupal\Core\Render\Markup;
|
||||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||||
use GuzzleHttp\ClientInterface;
|
use GuzzleHttp\ClientInterface;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the communication with the WissKI Cloud account manager daemon.
|
* Handles the communication with the WissKI Cloud account manager daemon.
|
||||||
|
|
@ -31,14 +32,21 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $USER_POST_URL_PART = '/user';
|
private string $ACCOUNT_POST_URL_PART = '/account';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL path to the GET endpoint.
|
* The URL path to the GET endpoint.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private string $FILTER_BY_DATA_URL_PART = '/user/by_data';
|
private string $FILTER_BY_DATA_URL_PART = '/account/by_data';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL path to provision and validation GET endpoint.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $ACCOUNT_VALIDATION_URL_PART = '/account/validation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The string translation service.
|
* The string translation service.
|
||||||
|
|
@ -68,8 +76,6 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
*/
|
*/
|
||||||
protected Config $settings;
|
protected Config $settings;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mail manager.
|
* The mail manager.
|
||||||
*
|
*
|
||||||
|
|
@ -93,7 +99,8 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
ClientInterface $httpClient,
|
ClientInterface $httpClient,
|
||||||
ConfigFactoryInterface $configFactory,
|
ConfigFactoryInterface $configFactory,
|
||||||
MailManagerInterface $mailManager,
|
MailManagerInterface $mailManager,
|
||||||
LanguageManagerInterface $languageManager) {
|
LanguageManagerInterface $languageManager
|
||||||
|
) {
|
||||||
// Services from container.
|
// Services from container.
|
||||||
$this->stringTranslation = $stringTranslation;
|
$this->stringTranslation = $stringTranslation;
|
||||||
$this->messenger = $messenger;
|
$this->messenger = $messenger;
|
||||||
|
|
@ -108,9 +115,10 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
|
|
||||||
// Set the daemon URL and the URL parts class variables.
|
// Set the daemon URL and the URL parts class variables.
|
||||||
$this->DAEMON_URL = $settings->get('daemonUrl') ?: 'http://wisski_cloud_api_daemon:3000/wisski-cloud-daemon/api/v1';
|
$this->DAEMON_URL = $settings->get('daemonUrl') ?: 'http://wisski_cloud_api_daemon:3000/wisski-cloud-daemon/api/v1';
|
||||||
$this->USER_POST_URL_PART = $settings->get('userPostUrlPath') ?: '/user';
|
$this->USER_POST_URL_PART = $settings->get('accountPostUrlPath') ?: '/account';
|
||||||
$this->FILTER_BY_DATA_URL_PART = $settings->get('userFilterByData') ?: '/user/by_data';
|
$this->FILTER_BY_DATA_URL_PART = $settings->get('accountFilterByData') ?: '/account/by_data';
|
||||||
|
$this->USER_PROVISION_AND_VALIDATION_URL_PART = $settings->get('accountProvisionAndValidationUrlPart') ?: '/account/provision_and_validation';
|
||||||
|
$this->ACCOUNT_VALIDATION_URL_PART = $settings->get('accountValidationUrlPart') ?: '/account/validation';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,7 +128,7 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
* The account to add.
|
* The account to add.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* The response from the daemon (user id with validation code).
|
* The response from the daemon (account id with validation code).
|
||||||
*/
|
*/
|
||||||
public function addAccount(array $account): array {
|
public function addAccount(array $account): array {
|
||||||
$request = [
|
$request = [
|
||||||
|
|
@ -129,21 +137,25 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
],
|
],
|
||||||
'body' => json_encode($account),
|
'body' => json_encode($account),
|
||||||
];
|
];
|
||||||
$userPostUrl = $this->DAEMON_URL . $this->USER_POST_URL_PART;
|
$accountPostUrl = $this->DAEMON_URL . $this->ACCOUNT_POST_URL_PART;
|
||||||
$response = $this->httpClient->post($userPostUrl, $request);
|
$response = $this->httpClient->post($accountPostUrl, $request);
|
||||||
return array_merge(json_decode($response->getBody()->getContents(), TRUE), ['statusCode' => $response->getStatusCode()]);
|
return array_merge(json_decode($response->getBody()
|
||||||
|
->getContents(), TRUE), ['statusCode' => $response->getStatusCode()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an account with the given data already exists.
|
* Check if an account with the given data already exists.
|
||||||
*
|
*
|
||||||
* @param array $dataToCheck
|
* @param array $dataToCheck
|
||||||
* The data to check.
|
* The data to check. Possible keys are:
|
||||||
|
* - email
|
||||||
|
* - subdomain
|
||||||
|
* - username.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* The response from the daemon.
|
* The response from the daemon.
|
||||||
*/
|
*/
|
||||||
public function checkAccountData($dataToCheck): array {
|
public function checkAccountData(array $dataToCheck): array {
|
||||||
// Build the query string from the parameters.
|
// Build the query string from the parameters.
|
||||||
$query_string = http_build_query($dataToCheck);
|
$query_string = http_build_query($dataToCheck);
|
||||||
|
|
||||||
|
|
@ -170,6 +182,22 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the validation status of the given validation code.
|
||||||
|
*
|
||||||
|
* @param string $validationCode
|
||||||
|
* The validation code to check.
|
||||||
|
*
|
||||||
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
|
* The response from the daemon.
|
||||||
|
*/
|
||||||
|
public function validateAccount(string $validationCode): ResponseInterface {
|
||||||
|
$url = $this->DAEMON_URL . $this->ACCOUNT_VALIDATION_URL_PART . '/' . $validationCode;
|
||||||
|
return $this->httpClient->put($url);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a validation email to the given email address.
|
* Sends a validation email to the given email address.
|
||||||
*
|
*
|
||||||
|
|
@ -184,7 +212,8 @@ class WisskiCloudAccountManagerDaemonApiActions {
|
||||||
$langcode = $this->languageManager->getDefaultLanguage()->getId();
|
$langcode = $this->languageManager->getDefaultLanguage()->getId();
|
||||||
$to = $email;
|
$to = $email;
|
||||||
|
|
||||||
$validationLink = \Drupal::request()->getSchemeAndHttpHost() . '/wisski-cloud-account-manager/validate/' . $validationCode;
|
$validationLink = \Drupal::request()
|
||||||
|
->getSchemeAndHttpHost() . '/wisski-cloud-account-manager/validate/' . $validationCode;
|
||||||
|
|
||||||
$params['message'] = Markup::create($this->stringTranslation->translate('<p>Please validate your account by clicking on this <a href="@validationLink" target="_blank">link</a> or copy this to the address bar of your browser: <p>@validationLink</p>.</p>', ['@validationLink' => $validationLink]));
|
$params['message'] = Markup::create($this->stringTranslation->translate('<p>Please validate your account by clicking on this <a href="@validationLink" target="_blank">link</a> or copy this to the address bar of your browser: <p>@validationLink</p>.</p>', ['@validationLink' => $validationLink]));
|
||||||
$params['subject'] = $this->stringTranslation->translate('WissKI Cloud account validation');
|
$params['subject'] = $this->stringTranslation->translate('WissKI Cloud account validation');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
{# wisski_cloud_account_manager/templates/wisski_cloud_account_manager_validation_page.html.twig #}
|
||||||
|
<div>
|
||||||
|
{% if responseContents is not empty %}
|
||||||
|
<table class="wisski-cloud-account-manager-table">
|
||||||
|
<tr>
|
||||||
|
<th>Person name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Subdomain</th>
|
||||||
|
<th>Valid</th>
|
||||||
|
<th>Provisioned</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ responseContents.data.personName }}</td>
|
||||||
|
<td>{{ responseContents.data.email }}</td>
|
||||||
|
<td>{{ responseContents.data.username }}</td>
|
||||||
|
<td>{{ responseContents.data.subdomain }}</td>
|
||||||
|
<td class="valid">
|
||||||
|
{% if responseContents.data.valid == 1 %}
|
||||||
|
yes
|
||||||
|
{% elseif responseContents.data.valid == 0 %}
|
||||||
|
no
|
||||||
|
{% else %}
|
||||||
|
unknown
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="provisioned">{% if responseContents.data.provisioned == 1 %}
|
||||||
|
yes
|
||||||
|
{% elseif responseContents.data.provisioned == 0 %}
|
||||||
|
no
|
||||||
|
{% elseif responseContents.data.provisioned == 2 %}
|
||||||
|
ongoing
|
||||||
|
{% else %}
|
||||||
|
unknown
|
||||||
|
{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
<div class="wisski-cloud-account-manager-center">
|
||||||
|
{% if responseContents.data.valid == 1 and responseContents.data.provisioned == 1 %}
|
||||||
|
<p class="wisski-cloud-account-manager-success"><strong> Your account is valid and provisioned. You can now log in to your account at <a href="https://{{ responseContents.data.subdomain }}.wisski.cloud">https://{{ responseContents.data.subdomain }}.wisski.cloud</a>.</strong></p>
|
||||||
|
{% elseif responseContents.data.valid == 1 and responseContents.data.provisioned == 0 %}
|
||||||
|
<p class="wisski-cloud-account-manager-warning"><strong>Your account is valid but not yet provisioned. Please wait a few minutes and reload this page.</strong></p>
|
||||||
|
{% elseif responseContents.data.valid == 0 %}
|
||||||
|
<p class="wisski-cloud-account-manager-error"><strong>Your account is not valid. Please contact <a href="mailto:info@wiss-ki.eu">info@wiss-ki.eu</a> to resolve this issue.</strong></p>
|
||||||
|
{% else %}
|
||||||
|
<p class="wisski-cloud-account-manager-error"><strong>Something went wrong. Please contact <a href="mailto:info@wiss-ki.eu">info@wiss-ki.eu</a> to resolve this issue.</strong></p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
5
wisski_cloud_account_manager.libraries.yml
Normal file
5
wisski_cloud_account_manager.libraries.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
wisski_cloud_account_manager:
|
||||||
|
version: 1.x
|
||||||
|
css:
|
||||||
|
theme:
|
||||||
|
css/style.css: {}
|
||||||
|
|
@ -42,3 +42,15 @@ function wisski_cloud_account_manager_mail($key, &$message, $params) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_theme().
|
||||||
|
*/
|
||||||
|
function wisski_cloud_account_manager_theme($existing, $type, $theme, $path) {
|
||||||
|
return [
|
||||||
|
'wisski_cloud_account_manager_validation_page' => [
|
||||||
|
'variables' => ['responseContents' => NULL],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,22 @@ wisski_cloud_account.create:
|
||||||
requirements:
|
requirements:
|
||||||
_access: 'TRUE'
|
_access: 'TRUE'
|
||||||
|
|
||||||
|
wisski_cloud_account.validate:
|
||||||
|
path: '/wisski-cloud-account-manager/validate/{validationCode}'
|
||||||
|
defaults:
|
||||||
|
_controller: '\Drupal\wisski_cloud_account_manager\Controller\WisskiCloudAccountManagerController::validationPage'
|
||||||
|
_title: 'Check validation and provision of your WissKI Cloud account'
|
||||||
|
requirements:
|
||||||
|
_access: 'TRUE'
|
||||||
|
token: '[a-zA-Z0-9]+'
|
||||||
|
|
||||||
wisski_cloud_account.terms_and_conditions:
|
wisski_cloud_account.terms_and_conditions:
|
||||||
path: '/wisski-cloud-account-manager/terms-and-conditions'
|
path: '/wisski-cloud-account-manager/terms-and-conditions'
|
||||||
defaults:
|
defaults:
|
||||||
_controller: '\Drupal\wisski_cloud_account_manager\Controller\WisskiCloudAccountManagerController::termsAndConditions'
|
_controller: '\Drupal\wisski_cloud_account_manager\Controller\WisskiCloudAccountManagerController::termsAndConditionsPage'
|
||||||
_title: 'Terms and conditions'
|
_title: 'Terms and conditions'
|
||||||
requirements:
|
requirements:
|
||||||
_access: 'TRUE'
|
_access: 'TRUE'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue