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} 
0 commit comments