Forgot password link

Im trying to put in an anonymous link to forgotpw . the link does not seem to work. I’m assuming it is related to my security configuration (which I don’t fully understand). I’m hoping someone could look at my code and tell me what I’m doing wrong.

code from my login page:

login.addForgotPasswordListener(l-> {
log.debug(“forgot password”);
//login.getUI().ifPresent(ui->ui.navigate(“/forgotpw”));});
Optional ui = login.getUI();
if (ui.isPresent()) {
UI currentUI = ui.get();
currentUI.navigate(“/forgotpw”);
}
});

My forgot password page

@AnonymousAllowed

@Route(value = “/forgotpw”,autoLayout = true)

@Slf4j
public class ForgotUserNamePassword extends Div {

private String email;
private String userName;
private String code;


public ForgotUserNamePassword() {
    log.debug("in ForgotUserNamePassword");
    Paragraph p=new Paragraph("This will allow you to retrive a forgotton username, or reset your password");
    EmailField emailField = new EmailField("Email");
    add(p,emailField);
    HorizontalLayout hl = new HorizontalLayout();
    Button forgotUserName=new Button("Forgot User Name");
    Button resetPassword=new Button("Reset Password");
    hl.add(forgotUserName,resetPassword);
    add(hl);
    forgotUserName.addClickListener(e->{
        email=emailField.getValue();
        Notifications.selectItemFirst();
    });
    resetPassword.addClickListener(e->{
        Notifications.selectItemFirst();
    });

}

And my security config

private RequestMatcher permittedAntMatchers() {
return Stream.of(new String{“/forgotpw**”, “/srv/**”})
.map(path → PathPatternRequestMatcher.withDefaults().matcher(path))
.toArray(RequestMatcher::new);
}

@Override
protected void configure(HttpSecurity http) throws Exception {
  //  super.configure(http);
    http.authorizeHttpRequests(auth -> auth.requestMatchers(permittedAntMatchers())
            .permitAll());



    setLoginView(http, LoginView.class); // not sure about this
    super.configure(http);
}

Thanks

You might wanna change this to false. If your layout is annotated with more strict security - it can’t be rendered.

Thanks so much. That was the issue. I’ve spent many hours looking at the wrong thing.