From 83b7be5fbfde6104beee41c06dfd046b24b9ee5f Mon Sep 17 00:00:00 2001
From: Ioannis Igoumenos We have sent an email with a confirmation link to your email address %MAIL%. In order to complete the sign-up process, please click the confirmation link. If you do not find the email in your Inbox, please check your Spam or Junk folder for an email from \"RCIAM Notifications\". If you do find the email in these folders, mark the email as \"safe\" or \"not spam\" to ensure that you receive any future notifications about your RCIAM ID. You can also click the \"Resend Verfication Email\" button below to have another email sent to you."
+ "petition_invalidate_msg": {
+ "en": " This action will invalidate any previous confirmation links. This action will invalidate any previous confirmation links. We have sent an email with a confirmation link to your email address %MAIL%. In order to complete the sign-up process, please click the confirmation link. If you do not find the email in your Inbox, please check your Spam or Junk folder for an email from \"RCIAM Notifications\". If you do find the email in these folders, mark the email as \"safe\" or \"not spam\" to ensure that you receive any future notifications about your RCIAM ID. You can also click the \"Resend Verfication Email\" button below to have another email sent to you."
+ },
+ "resend_confirmation_email": {
+ "en": "Please verify your email address by clicking the link in the email we sent you"
+ },
+ "yes": {
+ "en": "Resend Verfication Email"
}
}
diff --git a/lib/Auth/Process/COmanageDbClient.php b/lib/Auth/Process/COmanageDbClient.php
index 44d1aa4..bc06f69 100644
--- a/lib/Auth/Process/COmanageDbClient.php
+++ b/lib/Auth/Process/COmanageDbClient.php
@@ -349,6 +349,7 @@ public function process(&$state)
$pt_noty = [
'level' => $petition_handler->getBannerClass(),
'description' => $petition_handler->getUserNotify(),
+ 'title' => 'resend_confirmation_email',
//'status' => 'account_pending_confirmation', // This is a dictionary key
'icon' => 'email.gif',
'yes_btn_show' => true,
@@ -400,11 +401,7 @@ public function process(&$state)
// Get all the data from the COPerson and import them in the state
$this->retrieveCOPersonData($state);
} catch (Error\Error $e) {
- if(method_exists($e, 'show')) {
- $e->show();
- } else {
- $this->showError($e);
- }
+ $e->show();
}
}
@@ -1062,25 +1059,36 @@ private function retrieveCOPersonData(&$state)
}
// XXX Check if the identifier is an authenticator
if (!$org_identity->isIdpIdentLogin()) {
- // Normally, this should not happen
- $err_msg = 'The identifier - ' . $orgId . ' - = $this->t('{attrauthcomanage:noty:title}') ?> = $this->t('{attrauthcomanage:noty:' . $this->data['noty']['title'] . '}') ?>
is not present in your account or is not a valid authenticator.
Please contact support for further assistance.';
- throw new Exception($err_msg);
+ $this->showError($err_msg);
}
// XXX Check if the identifier is valid or has expired
- if ($this->isIdpIdentExpired($orgId, $orgIdentifiers)) {
+ if ($org_identity->isIdpIdentExpired()) {
// Normally, this should not happen
$err_msg = "The identifier - " . $orgId . " - is not a valid authenticator.";
$err_msg .= "
The subscription from " . end($state['saml:AuthenticatingAuthority']) . " expired.";
$err_msg .= "
Please contact support for further assistance.";
- throw new Exception($err_msg);
+ $this->showError($err_msg);
+ }
+
+ if ($org_identity->isIdpRemoved()) {
+ // Normally, this should not happen
+ $err_msg = "The identifier - " . $orgId . " - is not a valid authenticator.";
+ $err_msg .= "
The subscription from " . end($state['saml:AuthenticatingAuthority']) . " has been Removed.";
+ $err_msg .= "
Please contact support for further assistance.";
+ $this->showError($err_msg);
}
$loginId = $this->getCoPersonIdentifier($basicInfo['id'], $this->coUserIdType);
@@ -1634,7 +1524,9 @@ private function getTermsAgreementValid($personId)
. var_export($result, true));
return $result;
} else {
- throw new Exception('Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true));
+ throw new Error\Error(
+ ['UNHANDLEDEXCEPTION', 'Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true)]
+ );
}
return $result;
@@ -1675,7 +1567,9 @@ private function getTermsAgreementRevisioned($personId)
. var_export($result, true));
return $result;
} else {
- throw new Exception('Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true));
+ throw new Error\Error(
+ ['UNHANDLEDEXCEPTION', 'Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true)]
+ );
}
return $result;
diff --git a/lib/Enrollment/PetitionHandler.php b/lib/Enrollment/PetitionHandler.php
index 0a31bad..e68285a 100644
--- a/lib/Enrollment/PetitionHandler.php
+++ b/lib/Enrollment/PetitionHandler.php
@@ -130,7 +130,9 @@ protected function runQueryPetitionFromPersonIdPetStatus($petition_status, $co_i
. var_export($result, true));
return $result;
} else {
- throw new Exception('Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true));
+ throw new Error\Error(
+ ['UNHANDLEDEXCEPTION', 'Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true)]
+ );
}
return $result;
diff --git a/lib/User/AuthenticationEventHandler.php b/lib/User/AuthenticationEventHandler.php
index 4ee55ca..7019691 100644
--- a/lib/User/AuthenticationEventHandler.php
+++ b/lib/User/AuthenticationEventHandler.php
@@ -185,7 +185,9 @@ public function getLastAuthenticationEvent($identifier): array
return $result;
} else {
- throw new Exception('Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true));
+ throw new Error\Error(
+ ['UNHANDLEDEXCEPTION', 'Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true)]
+ );
}
return [];
diff --git a/lib/User/OrgIdentity.php b/lib/User/OrgIdentity.php
new file mode 100644
index 0000000..e67e4d0
--- /dev/null
+++ b/lib/User/OrgIdentity.php
@@ -0,0 +1,238 @@
+org_identity_identifier = $org_identity_identifier;
+ }
+
+ /**
+ * Fetch all the Login enabled Identifiers linked to OrgIdentities. Define whether these identifiers are authenticators or not
+ *
+ * @param string $personId The CO Person ID
+ * @param array $orgIdentTypeList
+ *
+ * @return array|null Return an array of identifiers, column headers [ident.type, ident.identifier, ident.login, ident.org_identity_id]
+ * @throws Exception
+ */
+ public function getLoginOrgIdentifiers($personId, $orgIdentTypeList)
+ {
+ $this->org_ident_list = $this->getOrgIdentifiers($personId, $orgIdentTypeList, true);
+
+ return $this->org_ident_list;
+ }
+
+ /**
+ * Fetch all the NON Login Identifiers linked to OrgIdentities. Define whether these identifiers are authenticators or not
+ *
+ * @param string $personId The CO Person ID
+ * @param array $orgIdentTypeList
+ *
+ * @return array|null Return an array of identifiers, column headers [ident.type, ident.identifier, ident.login, ident.org_identity_id]
+ * @throws Exception
+ */
+ public function getNonLoginOrgIdentifiers($personId, $orgIdentTypeList)
+ {
+ $this->org_ident_list = $this->getOrgIdentifiers($personId, $orgIdentTypeList, false);
+
+ return $this->org_ident_list;
+ }
+
+ /**
+ * Fetch all the Identifiers linked to OrgIdentities. Define whether these identifiers are authenticators or not
+ *
+ * @param string $personId The CO Person ID
+ * @param array $orgIdentTypeList
+ * @param bool $isLogin , true, false or null are allowed
+ *
+ * @return array|null Return an array of identifiers, column headers [ident.type, ident.identifier, ident.login, ident.org_identity_id]
+ * @throws Exception
+ */
+ private function getOrgIdentifiers($personId, $orgIdentTypeList, $isLogin = null)
+ {
+ Logger::debug('[attrauthcomanage] getOrgIdentifiers: personId=' . var_export($personId, true));
+
+ $db = Database::getInstance();
+ $this->orgIdIdentQuery = str_replace(
+ ':coOrgIdType',
+ "'" . implode("','", $orgIdentTypeList) . "'",
+ $this->orgIdIdentQuery
+ );
+ if (is_null($isLogin)) {
+ $isLoginConditionStr = '';
+ } else {
+ $isLoginCondition = ($isLogin) ? 'true' : 'false';
+ $isLoginConditionStr = ' and ident.login=' . $isLoginCondition;
+ }
+
+ $this->orgIdIdentQuery = str_replace(
+ ':isLogin',
+ $isLoginConditionStr,
+ $this->orgIdIdentQuery
+ );
+ $queryParams = [
+ 'coPersonId' => [$personId, PDO::PARAM_INT],
+ ];
+ $stmt = $db->read($this->orgIdIdentQuery, $queryParams);
+
+ if ($stmt->execute()) {
+ if ($result = $stmt->fetchall(PDO::FETCH_GROUP | PDO::FETCH_ASSOC)) {
+ Logger::debug(
+ "[attrauthcomanage] getOrgIdentifiers: result="
+ . var_export($result, true)
+ );
+
+ return $result;
+ }
+ } else {
+ throw new Error\Error(
+ [
+ 'UNHANDLEDEXCEPTION',
+ 'Failed to communicate with COmanage Registry: ' . var_export($db->getLastError(), true)
+ ]
+ );
+ }
+
+ return null;
+ }
+
+ /**
+ * Check whether the identifier fetched from the IdP is available in the list of my Identifiers
+ * and marked as a login identifier
+ *
+ * @return bool
+ */
+ public function isIdpIdentLogin(): bool
+ {
+ if (empty($this->org_ident_list) || empty($this->org_identity_identifier)) {
+ return false;
+ }
+ foreach ($this->org_ident_list as $identifierTypes) {
+ foreach ($identifierTypes as $ident) {
+ if ($ident['identifier'] === $this->org_identity_identifier
+ && $ident['login']) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check whether the identifier fetched from the IdP is available in the list of my Identifiers
+ * and marked as Removed
+ *
+ * @return bool
+ */
+ public function isIdpRemoved(): bool
+ {
+ if (empty($this->org_ident_list) || empty($this->org_identity_identifier)) {
+ return false;
+ }
+ foreach ($this->org_ident_list as $identifierTypes) {
+ foreach ($identifierTypes as $ident) {
+ if ($ident['identifier'] === $this->org_identity_identifier
+ && $ident['org_status'] == OrgIdentityStatusEnum::Removed) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check whether the identifier fetched from the IdP has expired
+ * If valid from and valid through fields are empty we assume that the Identifier will never expire
+ *
+ * @return bool|null true(is expired), false(is not expired), null if either of the parameters are empty
+ * @throws Exception
+ * @todo make timezone configuration
+ */
+ public function isIdpIdentExpired()
+ {
+ if (empty($this->org_ident_list) || empty($this->org_identity_identifier)) {
+ return null;
+ }
+ foreach ($this->org_ident_list as $identifierTypes) {
+ foreach ($identifierTypes as $ident) {
+ if ($ident['identifier'] === $this->org_identity_identifier) {
+ $current_date = new \DateTime('now', new \DateTimeZone('Etc/UTC'));
+ if (empty($ident['org_valid_from']) && empty($ident['org_valid_through'])) {
+ return false;
+ } elseif (empty($ident['org_valid_from']) && !empty($ident['org_valid_through'])) {
+ $valid_through = new \DateTime($ident['org_valid_through'], new \DateTimeZone('Etc/UTC'));
+
+ return !($valid_through >= $current_date);
+ } elseif (!empty($ident['org_valid_from']) && empty($ident['org_valid_through'])) {
+ $valid_from = new \DateTime($ident['org_valid_from'], new \DateTimeZone('Etc/UTC'));
+
+ return !($current_date >= $valid_from);
+ } elseif (!empty($ident['org_valid_from']) && !empty($ident['org_valid_through'])) {
+ $valid_from = new \DateTime($ident['org_valid_from'], new \DateTimeZone('Etc/UTC'));
+ $valid_through = new \DateTime($ident['org_valid_through'], new \DateTimeZone('Etc/UTC'));
+ if ($valid_through >= $current_date
+ && $current_date > $valid_from) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
From fd4a78a93d0b089b2c03cb73166a8bd0eab806d2 Mon Sep 17 00:00:00 2001
From: Ioannis Igoumenos
Please contact our support and make sure to include the error message above."
+ },
+ "org_identity_nologin_banner": {
+ "en": "Organization Identity is not login enabled"
+ },
+ "org_identity_nologin_description": {
+ "en": "The identifier - %ORGID% - is not a valid authenticator. Please contact our support and make sure to include the error message above."
+ },
+ "org_identity_removed_banner": {
+ "en": "Organization Identity Removed"
+ },
+ "org_identity_removed_description": {
+ "en": "The identifier - %ORGID% - is not a valid authenticator. The subscription from %AUTHNAUTHORITY% has been Removed.
Please contact our support and make sure to include the error message above."
},
"petition_info": {
"en": "The identifier %ORGIDENT% is in Email Pending Confirmation Status. Please check your Mail %MAIL% Inbox or Spam for further information. "
},
- "petition_user_notify": {
- "en": "
is not present in your account or is not a valid authenticator.
Please contact support for further assistance.';
- $this->showError($err_msg);
+ // Redirect to User notification
+ $pt_noty = [
+ 'level' => $org_identity->getBannerClass(),
+ 'description' => $org_identity->getUserNotify($state, 'nologin'),
+ 'status' => 'org_identity_nologin_banner', // This is a dictionary key
+ 'yes_btn_show' => false,
+ ];
+ $this->showNoty($pt_noty, $state);
}
// XXX Check if the identifier is valid or has expired
if ($org_identity->isIdpIdentExpired()) {
- // Normally, this should not happen
- $err_msg = "The identifier - " . $orgId . " - is not a valid authenticator.";
- $err_msg .= "
The subscription from " . end($state['saml:AuthenticatingAuthority']) . " expired.";
- $err_msg .= "
Please contact support for further assistance.";
- $this->showError($err_msg);
+ // Redirect to User notification
+ $pt_noty = [
+ 'level' => $org_identity->getBannerClass(),
+ 'description' => $org_identity->getUserNotify($state, 'expired'),
+ 'status' => 'org_identity_expired_banner', // This is a dictionary key
+ 'yes_btn_show' => false,
+ ];
+ $this->showNoty($pt_noty, $state);
}
if ($org_identity->isIdpRemoved()) {
- // Normally, this should not happen
- $err_msg = "The identifier - " . $orgId . " - is not a valid authenticator.";
- $err_msg .= "
The subscription from " . end($state['saml:AuthenticatingAuthority']) . " has been Removed.";
- $err_msg .= "
Please contact support for further assistance.";
- $this->showError($err_msg);
+ // Redirect to User notification
+ $pt_noty = [
+ 'level' => $org_identity->getBannerClass(),
+ 'description' => $org_identity->getUserNotify($state, 'removed'),
+ 'status' => 'org_identity_removed_banner', // This is a dictionary key
+ 'yes_btn_show' => false,
+ ];
+ $this->showNoty($pt_noty, $state);
}
$loginId = $this->getCoPersonIdentifier($basicInfo['id'], $this->coUserIdType);
diff --git a/lib/User/OrgIdentity.php b/lib/User/OrgIdentity.php
index e67e4d0..afbc5d7 100644
--- a/lib/User/OrgIdentity.php
+++ b/lib/User/OrgIdentity.php
@@ -12,6 +12,11 @@
class OrgIdentity
{
+ /**
+ * @var string
+ */
+ private $banner_class = 'info';
+
/**
* @var
*/
@@ -154,6 +159,8 @@ private function getOrgIdentifiers($personId, $orgIdentTypeList, $isLogin = null
*/
public function isIdpIdentLogin(): bool
{
+ $this->banner_class = 'warning';
+
if (empty($this->org_ident_list) || empty($this->org_identity_identifier)) {
return false;
}
@@ -161,6 +168,8 @@ public function isIdpIdentLogin(): bool
foreach ($identifierTypes as $ident) {
if ($ident['identifier'] === $this->org_identity_identifier
&& $ident['login']) {
+ // Reset the status of the banner
+ $this->banner_class = 'info';
return true;
}
}
@@ -184,6 +193,7 @@ public function isIdpRemoved(): bool
foreach ($identifierTypes as $ident) {
if ($ident['identifier'] === $this->org_identity_identifier
&& $ident['org_status'] == OrgIdentityStatusEnum::Removed) {
+ $this->banner_class = 'error';
return true;
}
}
@@ -213,11 +223,15 @@ public function isIdpIdentExpired()
return false;
} elseif (empty($ident['org_valid_from']) && !empty($ident['org_valid_through'])) {
$valid_through = new \DateTime($ident['org_valid_through'], new \DateTimeZone('Etc/UTC'));
-
+ if(!($valid_through >= $current_date)) {
+ $this->banner_class = 'error';
+ }
return !($valid_through >= $current_date);
} elseif (!empty($ident['org_valid_from']) && empty($ident['org_valid_through'])) {
$valid_from = new \DateTime($ident['org_valid_from'], new \DateTimeZone('Etc/UTC'));
-
+ if(!($current_date >= $valid_from)) {
+ $this->banner_class = 'error';
+ }
return !($current_date >= $valid_from);
} elseif (!empty($ident['org_valid_from']) && !empty($ident['org_valid_through'])) {
$valid_from = new \DateTime($ident['org_valid_from'], new \DateTimeZone('Etc/UTC'));
@@ -226,6 +240,7 @@ public function isIdpIdentExpired()
&& $current_date > $valid_from) {
return false;
} else {
+ $this->banner_class = 'error';
return true;
}
}
@@ -235,4 +250,27 @@ public function isIdpIdentExpired()
return false;
}
+
+ /**
+ * $params array $state
+ *
+ * @return array
+ */
+ public function getUserNotify($state, $status) {
+ $dictionary_list = [];
+ $dictionary_list['org_identity_'. $status . '_description'] = [
+ '%ORGID%' => $this->org_identity_identifier,
+ '%AUTHNAUTHORITY%' => end($state['saml:AuthenticatingAuthority'])
+ ];
+
+ return $dictionary_list;
+ }
+
+ /**
+ * @return string
+ */
+ public function getBannerClass(): string
+ {
+ return $this->banner_class;
+ }
}
\ No newline at end of file
diff --git a/templates/noty.tpl.php b/templates/noty.tpl.php
index 0d47202..439b9af 100644
--- a/templates/noty.tpl.php
+++ b/templates/noty.tpl.php
@@ -69,7 +69,9 @@
data['noty']['icon'])): ?>
-