Skip to content

Commit

Permalink
Switch logging on/off, better overriding capabilities of auth framework
Browse files Browse the repository at this point in the history
  • Loading branch information
SoltauFintel committed Jan 8, 2018
1 parent 9d2b969 commit c906f37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
allprojects {
version = "0.2.2"
version = "0.2.3"
group = 'de.mwvb.maja'
}

Expand Down
12 changes: 6 additions & 6 deletions maja-auth/src/main/java/de/mwvb/maja/auth/AuthPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static String getUserId(Session session) {
return session.attribute(USERID_ATTR);
}

static void setLoginData(boolean loggedIn, String name, String id, Session session) {
public static void setLoginData(boolean loggedIn, String name, String id, Session session) {
session.attribute(LOGGED_IN, loggedIn ? LOGGED_IN_YES : null);
session.attribute(USER_ATTR, name);
session.attribute(USERID_ATTR, id);
Expand Down Expand Up @@ -172,7 +172,9 @@ public String login(Request req, Response res, String name, String foreignId, St
String longId = service + "#" + foreignId;
setLoginData(true, name, longId, req.session());
rememberMe.rememberMe(rememberMeWanted, res, name, longId);
logLogin(name, longId);
if (isDebugLogging()) {
logLogin(name, longId);
}

// Redirect zur ursprünglich angewählten Seite
String uri = req.session().attribute("uri");
Expand All @@ -184,10 +186,8 @@ public String login(Request req, Response res, String name, String foreignId, St
return "";
}

protected void logLogin(String name, String longId) {
if (isDebugLogging()) {
Logger.debug("Login: " + name + " (" + longId + ")");
}
protected void logLogin(String name, String userId) {
Logger.debug("Login: " + name + " (" + userId + ")");
}

public boolean isDebugLogging() {
Expand Down
6 changes: 5 additions & 1 deletion maja-auth/src/main/java/de/mwvb/maja/auth/LogoutAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ public String run() {
Session session = req.session();
String userId = AuthPlugin.getUserId(session);
if (userId != null && isDebugLogging) {
Logger.debug("Logout: " + AuthPlugin.getUser(session) + " (" + userId + ")");
logLogout(AuthPlugin.getUser(session), userId);
}
rememberMe.forget(res, userId);
AuthPlugin.setLoginData(false, null, null, session);

res.redirect("/");
return "";
}

protected void logLogout(String user, String userId) {
Logger.debug("Logout: " + user + " (" + userId + ")");
}
}

0 comments on commit c906f37

Please sign in to comment.