Skip to content

Commit e1b55b1

Browse files
authored
Adds the RoleUser authorisation type (#636)
* Adding role user authorisation for initial assignment. * Adjusted the role user hash. * Added role user event types enum.
1 parent e867c40 commit e1b55b1

File tree

4 files changed

+57
-35
lines changed

4 files changed

+57
-35
lines changed

src/NoFrixion.MoneyMoov/Enums/AuthorisationType.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ public enum AuthorisationType
2323
Beneficiary = 3,
2424
Payrun = 4,
2525
MerchantToken = 5,
26-
UserInvite = 6
26+
UserInvite = 6,
27+
RoleUser = 7
2728
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//-----------------------------------------------------------------------------
2+
// Filename: RoleUserEventTypeEnum.cs
3+
//
4+
// Description: Enum for the different types of role user (assigning a user to a role)
5+
// events that can occur.
6+
//
7+
// Author(s):
8+
// Aaron Clauson ([email protected])
9+
//
10+
// History:
11+
// 22 Aug 2025 Aaron Clauson Created, Stillorgan Wood, Dublin, Ireland.
12+
//
13+
// License:
14+
// MIT.
15+
//-----------------------------------------------------------------------------
16+
17+
namespace NoFrixion.MoneyMoov.Enums;
18+
19+
public enum RoleUserEventTypeEnum
20+
{
21+
/// <summary>
22+
/// Something went wrong and the event type is unknown.
23+
/// </summary>
24+
Unknown = 0,
25+
26+
/// <summary>
27+
/// A user invite was authorised.
28+
/// </summary>
29+
Authorise = 1
30+
}

src/NoFrixion.MoneyMoov/Models/Roles/RoleUser.cs

100644100755
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
// History:
1010
// 19 08 2024 Donal O'Connor Created, Harcourt St, Dublin, Ireland.
11+
// 22 08 2025 Aaron Clauson Added GetApprovalHash for role user authorisatoions.
1112
//
1213
// License:
1314
// Proprietary NoFrixion.
@@ -36,9 +37,30 @@ public class RoleUser
3637

3738
public List<RoleUserAccount>? Accounts { get; set; }
3839

39-
public List<RoleUserMerchant>? Merchants { get; set; }
40-
4140
public User? User { get; set; }
4241

43-
public Role? Role { get; set; }
42+
public Role? Role { get; set; }
43+
44+
/// <summary>
45+
/// Gets a hash of the critical fields for the role user. This hash is
46+
/// used to ensure a role user's details are not modified between the time the
47+
/// authorisation is given and the time the role user assignment is enabled.
48+
/// Note the authorisation logic is currently only for the initial role user assignment.
49+
/// It is not intended to cover subsequent updates to the list of accounts the user gets access to
50+
/// for the role. In other words, once a user has been authorised for a role for a merchant they
51+
/// do not need to be re-authorised if the list of accounts changes. Because of this there is no
52+
/// nonce required in the approval hash as it does not need to accommodate updates.
53+
/// </summary>
54+
/// <returns>A hash of the role user's critical fields.</returns>
55+
public string GetApprovalHash()
56+
{
57+
var input =
58+
RoleID.ToString("N") +
59+
UserID.ToString("N") +
60+
(Accounts != null
61+
? string.Join(",", Accounts.OrderBy(a => a.AccountID).Select(a => a.AccountID.ToString("N")))
62+
: string.Empty);
63+
64+
return HashHelper.CreateHash(input);
65+
}
4466
}

src/NoFrixion.MoneyMoov/Models/Roles/RoleUserMerchant.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)