Implementing function for logout button

Hey guys, I have built a simple web page with few buttons. So far it is possible for users to log in.

How do I implement a function for logging out process? The user should be thrown back to the login page.

Can you guys help me here?


    private HorizontalLayout layoutRow = new HorizontalLayout();

    private H1 h1 = new H1();

    private HorizontalLayout layoutRow2 = new HorizontalLayout();

    private VerticalLayout layoutColumn2 = new VerticalLayout();

    private Button buttonPrimary = new Button();

    private Button buttonPrimary2 = new Button();

    public MFAPageView() {
        getContent().setHeightFull();
        getContent().setWidthFull();
        layoutRow.setWidthFull();
        layoutRow.addClassName(Gap.MEDIUM);
        h1.setText("MFA-Server: Webauthn-Token-Portal");
        getContent().setFlexGrow(1.0, layoutRow2);
        layoutRow2.setWidthFull();
        layoutRow2.addClassName(Gap.MEDIUM);
        layoutColumn2.addClassName(Gap.XLARGE);
        layoutColumn2.setWidth(null);
        buttonPrimary.setText("Webauthn-Token verwalten");
        buttonPrimary.setWidthFull();
        buttonPrimary.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
        buttonPrimary2.setText("Ausloggen");
        buttonPrimary2.setWidthFull();
        buttonPrimary2.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
        getContent().add(layoutRow);
        layoutRow.add(h1);
        getContent().add(layoutRow2);
        layoutRow2.add(layoutColumn2);
        layoutColumn2.add(buttonPrimary);
        layoutColumn2.add(buttonPrimary2);
    }
    
}

For plain Java app take a look at Securing Plain Java Applications | Advanced Security Topics | Security | Vaadin Docs

For Spring Boot project Enabling Security | Security | Vaadin Docs

Thank you for the links. I want to implement the function for the logout inside the MFAPageView class (code above). Is that possible?

yes