Skip to content

Commit f499739

Browse files
authored
Merge pull request #2735 from TechnologyEnhancedLearning/Develop/Fix/TD-2364-linking-admin-registered-unclaimed-account
TD-2364- Added action method without custom policy to verify dls account before linking.
2 parents ddba990 + 037f9ef commit f499739

File tree

2 files changed

+62
-50
lines changed

2 files changed

+62
-50
lines changed

DigitalLearningSolutions.Web/Controllers/Register/ClaimAccountController.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ public IActionResult Confirmation()
176176
return View(model);
177177
}
178178

179+
[HttpGet]
180+
public IActionResult VerifyLinkDlsAccount(string email, string code)
181+
{
182+
var userId = userService.GetUserAccountByEmailAddress(email).Id;
183+
var model = GetViewModelIfValidParameters(email, code, userId);
184+
var actionResult = ValidateClaimAccountViewModelForLinkingAccounts(userId, model);
185+
186+
if (actionResult != null)
187+
{
188+
return actionResult;
189+
}
190+
191+
return RedirectToAction("LinkDlsAccount", new { email, code });
192+
}
193+
179194
[Authorize(Policy = CustomPolicies.BasicUser)]
180195
[HttpGet]
181196
public IActionResult LinkDlsAccount(string email, string code)
@@ -219,23 +234,20 @@ public IActionResult AccountsLinked(string centreName)
219234
return View(model);
220235
}
221236

222-
[Authorize(Policy = CustomPolicies.BasicUser)]
223237
[HttpGet]
224238
public IActionResult WrongUser(string email, string centreName)
225239
{
226240
var model = new ClaimAccountViewModel { Email = email, CentreName = centreName };
227241
return View(model);
228242
}
229243

230-
[Authorize(Policy = CustomPolicies.BasicUser)]
231244
[HttpGet]
232245
public IActionResult AccountAlreadyExists(string email, string centreName)
233246
{
234247
var model = new ClaimAccountViewModel { Email = email, CentreName = centreName };
235248
return View(model);
236249
}
237250

238-
[Authorize(Policy = CustomPolicies.BasicUser)]
239251
[HttpGet]
240252
public IActionResult AdminAccountAlreadyExists(string email, string centreName)
241253
{

DigitalLearningSolutions.Web/Views/ClaimAccount/Index.cshtml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,66 @@
22
@model ClaimAccountViewModel
33

44
@{
5-
ViewData["Title"] = "Complete registration";
5+
ViewData["Title"] = "Complete registration";
66

7-
var routeData = new Dictionary<string, string> {
7+
var routeData = new Dictionary<string, string> {
88
{ "email", Model.Email },
99
{ "code", Model.RegistrationConfirmationHash },
1010
};
1111
}
1212

1313
<div class="nhsuk-grid-row">
14-
<div class="nhsuk-grid-column-full">
14+
<div class="nhsuk-grid-column-full">
1515

16-
<h1 class="nhsuk-heading-x1" id="app-page-heading">
17-
Complete registration
18-
</h1>
16+
<h1 class="nhsuk-heading-x1" id="app-page-heading">
17+
Complete registration
18+
</h1>
1919

20-
<p class="nhsuk-body-m">A new delegate record has been created for you by an administrator.</p>
20+
<p class="nhsuk-body-m">A new delegate record has been created for you by an administrator.</p>
2121

22-
<partial name="_DelegateRecordSummary" model="@Model" />
22+
<partial name="_DelegateRecordSummary" model="@Model" />
2323

24-
@if (Model.IdOfUserMatchingEmailIfAny != null)
25-
{
26-
if (Model.UserMatchingEmailIsActive)
27-
{
28-
<p class="nhsuk-body-m">
29-
A DLS user account is already registered with this email address. If that account belongs to you, you can link this delegate record to your login.
30-
</p>
24+
@if (Model.IdOfUserMatchingEmailIfAny != null)
25+
{
26+
if (Model.UserMatchingEmailIsActive)
27+
{
28+
<p class="nhsuk-body-m">
29+
A DLS user account is already registered with this email address. If that account belongs to you, you can link this delegate record to your login.
30+
</p>
3131

32-
<vc:action-link asp-controller="ClaimAccount"
33-
asp-action="LinkDlsAccount"
34-
asp-all-route-data="@routeData"
35-
link-text="Link this record" />
36-
}
37-
else
38-
{
39-
<p class="nhsuk-body-m">
40-
There is already an inactive DLS user account associated with this email address. To request reactivation of the user account and link this delegate record to the account, please contact <a href="mailto:@Model.SupportEmail">@Model.SupportEmail</a>.
41-
</p>
42-
}
43-
}
44-
else
45-
{
46-
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am an existing DLS user</h2>
47-
<p class="nhsuk-hint">
48-
If you have used DLS in the past (for example, at another organisation or university), we <b>recommend</b> that you link this record to your existing login.
49-
</p>
32+
<vc:action-link asp-controller="ClaimAccount"
33+
asp-action="VerifyLinkDlsAccount"
34+
asp-all-route-data="@routeData"
35+
link-text="Link this record" />
36+
}
37+
else
38+
{
39+
<p class="nhsuk-body-m">
40+
There is already an inactive DLS user account associated with this email address. To request reactivation of the user account and link this delegate record to the account, please contact <a href="mailto:@Model.SupportEmail">@Model.SupportEmail</a>.
41+
</p>
42+
}
43+
}
44+
else
45+
{
46+
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am an existing DLS user</h2>
47+
<p class="nhsuk-hint">
48+
If you have used DLS in the past (for example, at another organisation or university), we <b>recommend</b> that you link this record to your existing login.
49+
</p>
5050

51-
<vc:action-link asp-controller="ClaimAccount"
52-
asp-action="LinkDlsAccount"
53-
asp-all-route-data="@routeData"
54-
link-text="Use existing login and link delegate record" />
51+
<vc:action-link asp-controller="ClaimAccount"
52+
asp-action="LinkDlsAccount"
53+
asp-all-route-data="@routeData"
54+
link-text="Use existing login and link delegate record" />
5555

56-
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am a new DLS user</h2>
57-
<p class="nhsuk-hint">
58-
If you have never accessed DLS before, please activate this delegate record to log in. A new DLS user account will be created.
59-
</p>
56+
<h2 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">I am a new DLS user</h2>
57+
<p class="nhsuk-hint">
58+
If you have never accessed DLS before, please activate this delegate record to log in. A new DLS user account will be created.
59+
</p>
6060

61-
<vc:action-link asp-controller="ClaimAccount"
62-
asp-action="CompleteRegistration"
63-
asp-all-route-data="@routeData"
64-
link-text="Create new login and activate delegate record" />
65-
}
66-
</div>
61+
<vc:action-link asp-controller="ClaimAccount"
62+
asp-action="CompleteRegistration"
63+
asp-all-route-data="@routeData"
64+
link-text="Create new login and activate delegate record" />
65+
}
66+
</div>
6767
</div>

0 commit comments

Comments
 (0)