@@ -20,12 +20,10 @@ private async Task<EncryptInviteTokenResponse> EncryptInviteToken(EncryptInviteT
2020 {
2121 await Task . CompletedTask ;
2222
23- var expiryDate = DateTime . UtcNow . AddDays ( request . ValidDays ) ; // Example expiry date
23+ var expiryDate = DateTime . UtcNow . AddDays ( request . ValidDays ) ;
2424 var protector = dataProtectionProvider . CreateProtector ( nameof ( PortalInvitationTransformationEngine ) ) . ToTimeLimitedDataProtector ( ) ;
2525
26- // Combine referenceType and portalInvitation into a single string
27- var combinedData = $ "{ request . InviteType } :{ request . PortalInvitation } ";
28- var encryptedData = protector . Protect ( combinedData , expiryDate ) ;
26+ var encryptedData = protector . Protect ( request . PortalInvitation . ToString ( ) , expiryDate ) ;
2927
3028 var referenceLink = WebUtility . UrlEncode ( encryptedData ) ;
3129 return new EncryptInviteTokenResponse ( request . PortalInvitation , referenceLink ) ;
@@ -40,22 +38,8 @@ private async Task<DecryptInviteTokenResponse> DecryptInviteToken(DecryptInviteT
4038 var protector = dataProtectionProvider . CreateProtector ( nameof ( PortalInvitationTransformationEngine ) ) . ToTimeLimitedDataProtector ( ) ;
4139 var decryptedData = protector . Unprotect ( encryptedData ) ;
4240
43- // Split the decrypted data back into ReferenceType and PortalInvitation
44- var splitIndex = decryptedData . IndexOf ( ':' ) ;
45- if ( splitIndex == - 1 )
46- {
47- throw new InvalidOperationException ( $ "Invalid reference link format. decryptedData should be ReferenceType:PortalInvitation => '{ decryptedData } '") ;
48- }
49-
50- var referenceTypeString = decryptedData . Substring ( 0 , splitIndex ) ;
51- var inviteIdString = decryptedData . Substring ( splitIndex + 1 ) ;
52- var portalInvitation = Guid . Parse ( inviteIdString ) ;
53-
54- if ( ! Enum . TryParse < InviteType > ( referenceTypeString , out var referenceType ) )
55- {
56- throw new InvalidOperationException ( $ "Invalid reference type.") ;
57- }
41+ var portalInvitation = Guid . Parse ( decryptedData ) ;
5842
59- return new DecryptInviteTokenResponse ( portalInvitation , referenceType ) ;
43+ return new DecryptInviteTokenResponse ( portalInvitation ) ;
6044 }
6145}
0 commit comments