Skip to content

Commit

Permalink
Rename link Identity to Identifier Management
Browse files Browse the repository at this point in the history
  • Loading branch information
Sae126V committed Oct 17, 2024
1 parent ebbb7e2 commit 68b8410
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ function Get_User_Status_HTML()
$HTML .= "Unregistered user<br />";
$HTML .= "<br/><a href=\"index.php?Page_Type=Register\">".
"Register</a><br/>".
"<a href=\"index.php?Page_Type=Link_Identity\">".
"<a href=\"index.php?Page_Type=Identifier_Management\">".
"Link Identity/Recover Account</a>";

$HTML .="</div>";
return $HTML;
}
$HTML .= "Registered as: <br />".$user->getForename() . " " . $user->getSurname() . "<br /><br />";
$HTML .= Get_User_Info_HTML($user);
$HTML .= "<br/><a href=\"index.php?Page_Type=Link_Identity\">" . "Link Identity/Recover Account</a><br/>";
$HTML .= "<br/><a href=\"index.php?Page_Type=Identifier_Management\">";
$HTML .= "Link Identity/Recover Account</a><br/>";
$HTML .= "</div>";
return $HTML;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
require_once __DIR__.'/utils.php';

/**
* Controller for a link identity request.
* Controller for a identifier management request.
* @global array $_POST only set if the browser has POSTed data
* @return null
*/
function link_identity() {
function identifier_management()
{
//Check the portal is not in read only mode, returns exception if it is
checkPortalIsNotReadOnly();

Expand Down Expand Up @@ -56,12 +57,16 @@ function draw() {
$params['otherIdentifiers'][] = $identifier;
}
}
show_view('user/link_identity_rejected.php', $params);
show_view('user/identifier_management_rejected.php', $params);
die();
}
}

show_view('user/link_identity.php', $params, 'Link Identity');
show_view(
'user/identifier_management.php',
$params,
'Identifier Management'
);
}

function submit() {
Expand Down Expand Up @@ -89,7 +94,14 @@ function submit() {
}

try {
\Factory::getLinkIdentityService()->newLinkIdentityRequest($primaryIdString, $currentIdString, $primaryAuthType, $currentAuthType, $givenEmail);
\Factory::getIdentifierManagementService()
->newIdentifierManagementRequest(
$primaryIdString,
$currentIdString,
$primaryAuthType,
$currentAuthType,
$givenEmail
);
} catch(\Exception $e) {
show_view('error.php', $e->getMessage());
die();
Expand All @@ -106,5 +118,5 @@ function submit() {
$params['requestText'] = 'identity linking';
}

show_view('user/link_identity_accepted.php', $params);
show_view('user/identifier_management_accepted.php', $params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ function validate_identity_link() {
}

try {
$request = Factory::getLinkIdentityService()->confirmIdentityLinking($code, $currentIdString);
$request = Factory::getIdentifierManagementService()
->confirmIdentityLinking(
$code,
$currentIdString
);
} catch(\Exception $e) {
show_view('error.php', $e->getMessage());
die();
Expand All @@ -37,5 +41,5 @@ function validate_identity_link() {
$params['requestText'] = 'linked';
}

show_view('user/linked_identity.php', $params);
show_view('user/identifier_management_linked.php', $params);
}
9 changes: 5 additions & 4 deletions htdocs/web_portal/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,15 @@ function Draw_Page($Page_Type) {
require_once __DIR__ . '/controllers/site/delete_api_auth.php';
delete_entity();
break;
case "Link_Identity" :
case "Identifier_Management" :
rejectIfNotAuthenticated();
require_once __DIR__ . '/controllers/user/link_identity.php';
link_identity();
require_once __DIR__ . '/controllers/user/identifier_management.php';
identifier_management();
break;
case "User_Validate_Identity_Link" :
rejectIfNotAuthenticated();
require_once __DIR__ . '/controllers/user/link_identity_user_validate.php';
require_once __DIR__ . '/controllers'
. '/user/identifier_management_user_validate.php';
validate_identity_link();
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion htdocs/web_portal/javascript/linking.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$(document).ready(function() {
// Add the jQuery form change event handlers
$('#linkIdentityForm').find(":input").change(function() {
$('#identifierManagementForm').find(":input").change(function() {
validate();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
<br />
<div class=Form_Holder>
<div class=Form_Holder_2>
<form name="Link_Identity" action="index.php?Page_Type=Link_Identity"
method="post" class="inputForm" id="linkIdentityForm">
<form
name="Identifier_Management"
action="index.php?Page_Type=Identifier_Management"
method="post"
class="inputForm"
id="identifierManagementForm"
>
<div>
Your current ID string (e.g. certificate DN) is: <label><?php echo $params['idString']; ?></label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
registered to your account. Please follow the instructions contained within it to
complete your <?php echo $params['requestText']; ?>.</p>

<p>If you did not receive an email, please check the above details are correct, and the
<a href="index.php?Page_Type=Link_Identity">guidance on identity linking and account recovery</a>.</p>
<p>
If you did not receive an email,
please check the above details are correct, and the
<a href="index.php?Page_Type=Identifier_Management">
guidance on identity linking and account recovery</a>.
</p>
</div>
2 changes: 1 addition & 1 deletion lib/Doctrine/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
require_once $entitiesPath."/RoleActionRecord.php";
require_once $entitiesPath."/APIAuthentication.php";
require_once $entitiesPath."/UserIdentifier.php";
require_once $entitiesPath."/LinkIdentityRequest.php";
require_once $entitiesPath."/IdentifierManagementRequest.php";

//if (!class_exists("Doctrine\Common\Version", false)) {
// require_once __DIR__."/bootstrap_doctrine.php";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* a confirmation code that is sent to the user's existing email
* address - they need to provide the code to complete the identity linking transaction.
*
* @Entity @Table(name="LinkIdentityRequests")
* @Entity @Table(name="IdentifierManagementRequests")
*/
class LinkIdentityRequest {
class IdentifierManagementRequest {

/** @Id @Column(type="integer") @GeneratedValue */
protected $id;
Expand Down
23 changes: 14 additions & 9 deletions lib/Gocdb_Services/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Factory {
private static $exService = null;
private static $notificationService = null;
private static $emailService = null;
private static $linkIdentityService = null;
private static $identifierManagementService = null;
private static $APIAuthenticationService = null;

public static $properties = array();
Expand Down Expand Up @@ -349,16 +349,21 @@ public static function getProjectService() {
}

/**
* Singleton Link Identity service
* @return org\gocdb\services\LinkIdentity
* Singleton Identifier Management service
* @return org\gocdb\services\IdentifierManagement
*/
public static function getLinkIdentityService() {
if (self::$linkIdentityService == null) {
require_once __DIR__ . '/LinkIdentity.php';
self::$linkIdentityService = new org\gocdb\services\LinkIdentity();
self::$linkIdentityService->setEntityManager(self::getEntityManager());
public static function getIdentifierManagementService()
{
if (self::$identifierManagementService == null) {
require_once __DIR__ . '/IdentifierManagement.php';

self::$identifierManagementService = new org\gocdb\services\IdentifierManagement();
self::$identifierManagementService->setEntityManager(
self::getEntityManager()
);
}
return self::$linkIdentityService;

return self::$identifierManagementService;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace org\gocdb\services;

require_once __DIR__ . '/AbstractEntityService.php';
class LinkIdentity extends AbstractEntityService {
class IdentifierManagement extends AbstractEntityService {

/**
* Processes an identity link request
Expand All @@ -12,7 +12,13 @@ class LinkIdentity extends AbstractEntityService {
* @param string $currentAuthType auth type of current ID string
* @param string $givenEmail email of primary user
*/
public function newLinkIdentityRequest($primaryIdString, $currentIdString, $primaryAuthType, $currentAuthType, $givenEmail) {
public function newIdentifierManagementRequest(
$primaryIdString,
$currentIdString,
$primaryAuthType,
$currentAuthType,
$givenEmail
) {

$serv = \Factory::getUserService();

Expand Down Expand Up @@ -46,8 +52,16 @@ public function newLinkIdentityRequest($primaryIdString, $currentIdString, $prim
// Generate confirmation code
$code = $this->generateConfirmationCode($primaryIdString);

// Create link identity request
$linkIdentityReq = new \LinkIdentityRequest($primaryUser, $currentUser, $code, $primaryIdString, $currentIdString, $primaryAuthType, $currentAuthType);
// Create identifier management request
$identifierManagementReq = new \IdentifierManagementRequest(
$primaryUser,
$currentUser,
$code,
$primaryIdString,
$currentIdString,
$primaryAuthType,
$currentAuthType
);

// Recovery or identity linking
if ($currentUser === null) {
Expand All @@ -59,7 +73,7 @@ public function newLinkIdentityRequest($primaryIdString, $currentIdString, $prim
// Apply change
try {
$this->em->getConnection()->beginTransaction();
$this->em->persist($linkIdentityReq);
$this->em->persist($identifierManagementReq);
$this->em->flush();

// Send confirmation email(s) to primary user, and current user if registered with a different email
Expand Down Expand Up @@ -172,13 +186,13 @@ private function generateConfirmationCode($idString) {
}

/**
* Gets a link identity request from the database based on user ID
* Gets a identifier management request from the database based on user ID
* @param integer $userId userid of the request to be linked
* @return arraycollection
*/
private function getRequestByUserId($userId) {
$dql = "SELECT l
FROM LinkIdentityRequest l
FROM IdentifierManagementRequest l
JOIN l.primaryUser pu
JOIN l.currentUser cu
WHERE pu.id = :id OR cu.id = :id";
Expand All @@ -192,14 +206,16 @@ private function getRequestByUserId($userId) {
}

/**
* Gets a link identity request from the database based on current ID string
* Gets a identifier management request from the database
* based on current ID string.
*
* ID string may be present as primary or current user
* @param string $idString ID string of user to be linked in primary account
* @return arraycollection
*/
private function getRequestByIdString($idString) {
$dql = "SELECT l
FROM LinkIdentityRequest l
FROM IdentifierManagementRequest l
WHERE l.primaryIdString = :idString
OR l.currentIdString = :idString";

Expand All @@ -218,7 +234,7 @@ private function getRequestByIdString($idString) {
*/
public function getRequestByConfirmationCode($code) {
$dql = "SELECT l
FROM LinkIdentityRequest l
FROM IdentifierManagementRequest l
WHERE l.confirmCode = :code";

$request = $this->em
Expand Down
2 changes: 1 addition & 1 deletion resources/DeleteOldRequestsRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
echo "Querying identity linking and account recovery requests\n\n";

$em = $entityManager;
$dql = "SELECT l FROM LinkIdentityRequest l";
$dql = "SELECT l FROM IdentifierManagementRequest l";
$requests = $entityManager->createQuery($dql)->getResult();

// Remove requests older than one day
Expand Down
2 changes: 1 addition & 1 deletion tests/doctrine/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
require_once $entitiesPath."/Project.php";
require_once $entitiesPath."/ServiceGroup.php";
require_once $entitiesPath."/ServiceGroupProperty.php";
require_once $entitiesPath."/LinkIdentityRequest.php";
require_once $entitiesPath."/IdentifierManagementRequest.php";
require_once $entitiesPath."/PrimaryKey.php";
require_once $entitiesPath."/ArchivedNGI.php";
require_once $entitiesPath."/ArchivedService.php";
Expand Down
2 changes: 1 addition & 1 deletion tests/doctrine/truncateDataTables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<Downtimes_EndpointLocations/>

<Users/>
<LinkIdentityRequests/>
<IdentifierManagementRequests/>
<RoleTypes/>
<Roles/>

Expand Down

0 comments on commit 68b8410

Please sign in to comment.