InputDialog on LoginScreen

Hello,

I have a standard login screen and I’m now trying to implement a forgotten password flow in it.

I have a button called “Forgotten password” and what I want to achieve is to open a dialog with a single input value - the user’s registration email. When they input it I’d like to send them an email with a reset link.

I’m a bit stuck though - it seems that the anonymous user has access to the Dialog and OptionsDialog classes but not the InputDialog one:

Denied access to [screen: inputDialog] for user [anonymous] by io.jmix.securityui.constraint.UiShowScreenConstraint

I tried defining an Anonymous user role and gave them access to the input dialog UI element, hoping it would override the default anonymous access list, but it didn’t do anything.

Any idea on how I can achieve this?

Hi,

  1. Create the AnonymousRole resource role and allow access to inputDialog:
import io.jmix.security.role.annotation.ResourceRole;
import io.jmix.securityui.role.annotation.ScreenPolicy;

@ResourceRole(name = "AnonymousRole", code = AnonymousRole.CODE)
public interface AnonymousRole {

    String CODE = "anonymous-role";


    @ScreenPolicy(screenIds = "inputDialog")
    void screens();
}
  1. Grant AnonymousRole to the anonymous user in DatabaseUserRepository :
@Override
protected void initAnonymousUser(User anonymousUser) {
    Collection<GrantedAuthority> authorities = getGrantedAuthoritiesBuilder()
            .addResourceRole(AnonymousRole.CODE)
            .build();
    anonymousUser.setAuthorities(authorities);
}
  1. In the application.properties file enable anonymous access:
# enable anonymous access
jmix.ui.allow-anonymous-access=true

See doc for more detail.

Regards,
Gleb