Hi,
VaadinSession already contain a correct locale but the problem is that framework doesn’t know how to get locale in case of RememberMeAuthenticationToken because its details object is not an instance of ClientDetails.
To fix the problem, implement AuthenticationLocaleResolver that supports RememberMeAuthenticationToken:
import com.vaadin.flow.server.VaadinSession;
import io.jmix.core.JmixOrder;
import io.jmix.core.security.AuthenticationLocaleResolver;
import org.jspecify.annotations.Nullable;
import org.springframework.security.authentication.RememberMeAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import java.util.Locale;
@Component("demo_RememberMeAuthenticationLocaleResolver")
public class RememberMeAuthenticationLocaleResolver implements AuthenticationLocaleResolver {
@Override
public boolean supports(Authentication authentication) {
return authentication instanceof RememberMeAuthenticationToken;
}
@Nullable
@Override
public Locale getLocale(Authentication authentication) {
if (VaadinSession.getCurrent() != null) {
return VaadinSession.getCurrent().getLocale();
}
return null;
}
@Override
public int getOrder() {
return JmixOrder.HIGHEST_PRECEDENCE;
}
}
I’ve created a GItHub issue to provide built-in AuthenticationLocaleResolver for RememberMeAuthenticationToken.
Regards,
Gleb