Skip to content

Commit 3407b72

Browse files
authored
Merge pull request #3173 from TechnologyEnhancedLearning/Develop/Feature/TD-3713-UpdateLastAccessedDateForAdminAccountsAndDelegateAccounts
TD-3713- Update LastAccessed Date For AdminAccounts And DelegateAccounts
2 parents 2a8b0a2 + 01774db commit 3407b72

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

DigitalLearningSolutions.Data/DataServices/LoginDataService.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
public interface ILoginDataService
77
{
88
void UpdateLastAccessedForUsersTable(int Id);
9+
10+
void UpdateLastAccessedForDelegatesAccountsTable(int Id);
11+
12+
void UpdateLastAccessedForAdminAccountsTable(int Id);
913
}
1014

1115
public class LoginDataService : ILoginDataService
@@ -29,5 +33,31 @@ public void UpdateLastAccessedForUsersTable(int Id)
2933
}
3034
);
3135
}
36+
37+
public void UpdateLastAccessedForDelegatesAccountsTable(int Id)
38+
{
39+
connection.Execute(
40+
@"UPDATE DelegateAccounts SET
41+
LastAccessed = GetUtcDate()
42+
WHERE ID = @Id",
43+
new
44+
{
45+
Id
46+
}
47+
);
48+
}
49+
50+
public void UpdateLastAccessedForAdminAccountsTable(int Id)
51+
{
52+
connection.Execute(
53+
@"UPDATE AdminAccounts SET
54+
LastAccessed = GetUtcDate()
55+
WHERE ID = @Id",
56+
new
57+
{
58+
Id
59+
}
60+
);
61+
}
3262
}
3363
}

DigitalLearningSolutions.Web/Controllers/LoginController.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,17 @@ int centreIdToLogInto
226226
IsPersistent = rememberMe,
227227
IssuedUtc = clockUtility.UtcNow,
228228
};
229+
var centreAccountSet = userEntity?.GetCentreAccountSet(centreIdToLogInto);
229230

230-
var adminAccount = userEntity!.GetCentreAccountSet(centreIdToLogInto)?.AdminAccount;
231+
if (centreAccountSet?.DelegateAccount?.Id != null)
232+
{
233+
loginService.UpdateLastAccessedForDelegatesAccountsTable(centreAccountSet.DelegateAccount.Id);
234+
}
231235

236+
var adminAccount = centreAccountSet?.AdminAccount;
232237
if (adminAccount?.Active == true)
233238
{
239+
loginService.UpdateLastAccessedForAdminAccountsTable(adminAccount.Id);
234240
sessionService.StartAdminSession(adminAccount.Id);
235241
}
236242

DigitalLearningSolutions.Web/Services/LoginService.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ List<int> idsOfCentresWithUnverifiedEmails
3232

3333
void UpdateLastAccessedForUsersTable(int Id);
3434

35+
void UpdateLastAccessedForDelegatesAccountsTable(int Id);
36+
37+
void UpdateLastAccessedForAdminAccountsTable(int Id);
38+
3539
Task<string> HandleLoginResult(
3640
LoginResult loginResult,
3741
TicketReceivedContext context,
@@ -59,6 +63,16 @@ public void UpdateLastAccessedForUsersTable(int Id)
5963
loginDataService.UpdateLastAccessedForUsersTable(Id);
6064
}
6165

66+
public void UpdateLastAccessedForDelegatesAccountsTable(int Id)
67+
{
68+
loginDataService.UpdateLastAccessedForDelegatesAccountsTable(Id);
69+
}
70+
71+
public void UpdateLastAccessedForAdminAccountsTable(int Id)
72+
{
73+
loginDataService.UpdateLastAccessedForAdminAccountsTable(Id);
74+
}
75+
6276
public LoginResult AttemptLogin(string username, string password)
6377
{
6478
var userEntity = userService.GetUserByUsername(username);

0 commit comments

Comments
 (0)