Showing consent screen text instead of scope name in consent part of Application page in Account console

Closes #13109
This commit is contained in:
Konstantinos Georgilakis 2022-07-15 16:52:31 +03:00 committed by Marek Posolda
parent c223291a1e
commit 2002fd983b
3 changed files with 4 additions and 3 deletions

View file

@ -311,7 +311,7 @@ public class AccountRestService {
private ConsentRepresentation modelToRepresentation(UserConsentModel model) {
List<ConsentScopeRepresentation> grantedScopes = model.getGrantedClientScopes().stream()
.map(m -> new ConsentScopeRepresentation(m.getId(), m.getName(), StringPropertyReplacer.replaceProperties(m.getConsentScreenText(), getProperties())))
.map(m -> new ConsentScopeRepresentation(m.getId(), m.getConsentScreenText()!= null ? m.getConsentScreenText() : m.getName(), StringPropertyReplacer.replaceProperties(m.getConsentScreenText(), getProperties())))
.collect(Collectors.toList());
return new ConsentRepresentation(grantedScopes, model.getCreatedDate(), model.getLastUpdatedDate());
}

View file

@ -33,6 +33,7 @@ import org.keycloak.credential.CredentialTypeMetadata;
import org.keycloak.events.Details;
import org.keycloak.events.EventType;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.ClientScopeModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.credential.OTPCredentialModel;
import org.keycloak.models.credential.PasswordCredentialModel;
@ -962,7 +963,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
assertFalse(app.getConsent().getGrantedScopes().isEmpty());
ConsentScopeRepresentation grantedScope = app.getConsent().getGrantedScopes().get(0);
assertEquals(clientScopeRepresentation.getId(), grantedScope.getId());
assertEquals(clientScopeRepresentation.getName(), grantedScope.getName());
assertEquals(clientScopeRepresentation.getAttributes().get(ClientScopeModel.CONSENT_SCREEN_TEXT) != null ? clientScopeRepresentation.getAttributes().get(ClientScopeModel.CONSENT_SCREEN_TEXT) : clientScopeRepresentation.getName(), grantedScope.getName());
}
@Test

View file

@ -224,7 +224,7 @@ export class ApplicationsPage extends React.Component<ApplicationsPageProps, App
{application.consent.grantedScopes.map((scope: GrantedScope, scopeIndex: number) => {
return (
<React.Fragment key={'scope-' + scopeIndex} >
<DescriptionListDescription><CheckIcon /> {scope.name}</DescriptionListDescription>
<DescriptionListDescription><CheckIcon />{Msg.localize(scope.name)}</DescriptionListDescription>
</React.Fragment>
)
})}