-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a page for Control Center login and logout links (#3748)
* Add a page for Control Center login and logout links * Add router ignore to link * First pass at editing. * Second pass at editing and formatting. --------- Co-authored-by: Russell J.T. Dyer <6652767+russelljtdyer@users.noreply.github.com>
- Loading branch information
1 parent
ab06427
commit 79127b6
Showing
3 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
articles/control-center/identity-management/login-logout.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
title: Login and Logout Links | ||
description: How to create login and logout links or buttons using Control Center identity management security. | ||
order: 40 | ||
--- | ||
|
||
|
||
= Login & Logout Links | ||
|
||
For users to login and logout, it can be useful to provide them with a link or button. This page explains how to do that in a Vaadin application when using the <<../identity-management#,Identity Management feature>> in Control Center. | ||
|
||
|
||
== Adding Login | ||
|
||
To add a login link or button to a Vaadin application, you'll need to create a component that redirects users to the login page provided by Control Center -- for when they click on the link or button. Here's an example of how you might do that: | ||
|
||
[source,java] | ||
---- | ||
public class MainLayout extends AppLayout { | ||
public MainLayout() { | ||
/* <1> */ | ||
Button loginButton = new Button("Login", event -> { | ||
getUI().ifPresent(ui -> ui.getPage().setLocation("/oauth2/authorization/control-center")); | ||
}); | ||
/* <2> */ | ||
Anchor loginLink = new Anchor("/oauth2/authorization/control-center", "Login"); | ||
loginLink.setRouterIgnore(true); | ||
addToNavbar(loginButton, loginLink); | ||
} | ||
} | ||
---- | ||
|
||
<1> This part creates a login button. | ||
<2> This creates a login link. You may not want to do both a button and a link, though. | ||
|
||
|
||
== Adding Logout | ||
|
||
To add a logout link or button to a Vaadin application, you'll need to create a component that triggers the logout process. Here's an example of how to create a button, only: | ||
|
||
[source,java] | ||
---- | ||
public class MainLayout extends AppLayout { | ||
public MainLayout(@Autowired AuthenticationContext authenticationContext) { | ||
Button logoutButton = new Button("Logout", click -> authenticationContext.logout()); | ||
addToNavbar(logoutButton); | ||
} | ||
} | ||
---- | ||
|
||
|
||
== Deploy the Application | ||
|
||
Deploy the application as described in <<../application-deployment#,Deploying a Vaadin Application with Control Center>>. Be sure to activate the Identity Management feature. |