Skip to content

Commit

Permalink
reorder sanity checks to properly throw invalidPersona when request s…
Browse files Browse the repository at this point in the history
…pecifies persona unknown to the dApp
  • Loading branch information
jakub-rdx committed Aug 6, 2024
1 parent 7a5a81f commit 359ff4a
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ class AuthorizeSpecifiedPersonaUseCase @Inject constructor(
var operationResult: Result<DAppData> = Result.failure(
RadixWalletException.DappRequestException.NotPossibleToAuthenticateAutomatically
)
if (incomingRequest.isMobileConnectRequest) {
return operationResult
}
(incomingRequest as? AuthorizedRequest)?.let { request ->
if (incomingRequest.needSignatures()) {
return@let
}
(request.authRequest as? AuthorizedRequest.AuthRequest.UsePersonaRequest)?.let {
val authorizedDapp = dAppConnectionRepository.getAuthorizedDApp(
dAppDefinitionAddress = AccountAddress.init(request.metadata.dAppDefinitionAddress)
Expand All @@ -62,11 +56,14 @@ class AuthorizeSpecifiedPersonaUseCase @Inject constructor(
respondWithInvalidPersona(incomingRequest)
return Result.failure(RadixWalletException.DappRequestException.InvalidPersona)
}
if (incomingRequest.needSignatures() || incomingRequest.isMobileConnectRequest) {
return operationResult
}
val authorizedPersonaSimple = authorizedDapp
.referencesToAuthorizedPersonas
.firstOrNull { authorizedPersonaSimple ->
authorizedPersonaSimple.identityAddress.string ==
(request.authRequest as? AuthorizedRequest.AuthRequest.UsePersonaRequest)?.identityAddress?.string
(request.authRequest as? AuthorizedRequest.AuthRequest.UsePersonaRequest)?.identityAddress?.string
}
if (authorizedPersonaSimple == null) {
respondWithInvalidPersona(incomingRequest)
Expand Down

0 comments on commit 359ff4a

Please sign in to comment.