diff options
author | James Moger <james.moger@gitblit.com> | 2012-04-25 17:01:00 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-04-25 17:01:00 -0400 |
commit | ea094a45b9a31076919ca23ba17e8ad27e90ebce (patch) | |
tree | 5c244104f6b9b4d35a87d37692b4c7e39ad1d8bd | |
parent | d2426e1eb5d07664b5c26c4247fae3325282d60d (diff) | |
download | gitblit-ea094a45b9a31076919ca23ba17e8ad27e90ebce.tar.gz gitblit-ea094a45b9a31076919ca23ba17e8ad27e90ebce.zip |
Added a logout hook to IUserService
-rw-r--r-- | src/com/gitblit/ConfigUserService.java | 9 | ||||
-rw-r--r-- | src/com/gitblit/FileUserService.java | 9 | ||||
-rw-r--r-- | src/com/gitblit/GitBlit.java | 12 | ||||
-rw-r--r-- | src/com/gitblit/GitblitUserService.java | 5 | ||||
-rw-r--r-- | src/com/gitblit/IUserService.java | 7 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/LogoutPage.java | 6 |
6 files changed, 47 insertions, 1 deletions
diff --git a/src/com/gitblit/ConfigUserService.java b/src/com/gitblit/ConfigUserService.java index 828ba762..f8eff9f3 100644 --- a/src/com/gitblit/ConfigUserService.java +++ b/src/com/gitblit/ConfigUserService.java @@ -200,6 +200,15 @@ public class ConfigUserService implements IUserService { }
/**
+ * Logout a user.
+ *
+ * @param user
+ */
+ @Override
+ public void logout(UserModel user) {
+ }
+
+ /**
* Retrieve the user object for the specified username.
*
* @param username
diff --git a/src/com/gitblit/FileUserService.java b/src/com/gitblit/FileUserService.java index b8d4a40e..02cf2b00 100644 --- a/src/com/gitblit/FileUserService.java +++ b/src/com/gitblit/FileUserService.java @@ -178,6 +178,15 @@ public class FileUserService extends FileSettings implements IUserService { }
/**
+ * Logout a user.
+ *
+ * @param user
+ */
+ @Override
+ public void logout(UserModel user) {
+ }
+
+ /**
* Retrieve the user object for the specified username.
*
* @param username
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 2b7ba3c1..a616bef7 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -481,6 +481,18 @@ public class GitBlit implements ServletContextListener { response.addCookie(userCookie);
}
}
+
+ /**
+ * Logout a user.
+ *
+ * @param user
+ */
+ public void logout(UserModel user) {
+ if (userService == null) {
+ return;
+ }
+ userService.logout(user);
+ }
/**
* Returns the list of all users available to the login service.
diff --git a/src/com/gitblit/GitblitUserService.java b/src/com/gitblit/GitblitUserService.java index ddb3ca77..7ad3db71 100644 --- a/src/com/gitblit/GitblitUserService.java +++ b/src/com/gitblit/GitblitUserService.java @@ -141,6 +141,11 @@ public class GitblitUserService implements IUserService { public UserModel authenticate(String username, char[] password) {
return serviceImpl.authenticate(username, password);
}
+
+ @Override
+ public void logout(UserModel user) {
+ serviceImpl.logout(user);
+ }
@Override
public UserModel getUserModel(String username) {
diff --git a/src/com/gitblit/IUserService.java b/src/com/gitblit/IUserService.java index 334bbedd..c3573db8 100644 --- a/src/com/gitblit/IUserService.java +++ b/src/com/gitblit/IUserService.java @@ -88,6 +88,13 @@ public interface IUserService { UserModel authenticate(String username, char[] password);
/**
+ * Logout a user.
+ *
+ * @param user
+ */
+ void logout(UserModel user);
+
+ /**
* Retrieve the user object for the specified username.
*
* @param username
diff --git a/src/com/gitblit/wicket/pages/LogoutPage.java b/src/com/gitblit/wicket/pages/LogoutPage.java index 15ef0e6e..4690ad11 100644 --- a/src/com/gitblit/wicket/pages/LogoutPage.java +++ b/src/com/gitblit/wicket/pages/LogoutPage.java @@ -19,13 +19,17 @@ import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebResponse;
import com.gitblit.GitBlit;
+import com.gitblit.models.UserModel;
import com.gitblit.wicket.GitBlitWebSession;
public class LogoutPage extends WebPage {
public LogoutPage() {
- GitBlitWebSession.get().invalidate();
+ GitBlitWebSession session = GitBlitWebSession.get();
+ UserModel user = session.getUser();
GitBlit.self().setCookie((WebResponse) getResponse(), null);
+ GitBlit.self().logout(user);
+ session.invalidate();
setRedirect(true);
setResponsePage(getApplication().getHomePage());
}
|