diff --git a/core/src/main/java/de/bstly/we/businesslogic/PermissionManager.java b/core/src/main/java/de/bstly/we/businesslogic/PermissionManager.java
index 5a8038b..030582a 100755
--- a/core/src/main/java/de/bstly/we/businesslogic/PermissionManager.java
+++ b/core/src/main/java/de/bstly/we/businesslogic/PermissionManager.java
@@ -280,13 +280,18 @@ public class PermissionManager implements UserDataProvider {
Instant permissionStarts = starts;
Instant permissionsExpires = expires;
+ if (permissionMapping.isLifetimeRound()) {
+ permissionStarts = InstantHelper.truncate(permissionStarts,
+ permissionMapping.getLifetimeUnit());
+ }
+
if (permissionsExpires == null) {
permissionsExpires = InstantHelper.plus(
permissionStarts == null ? Instant.now() : permissionStarts,
permissionMapping.getLifetime(), permissionMapping.getLifetimeUnit());
}
- boolean additional = true;
+ boolean additional = permissionMapping.isAddon();
for (JsonElement anwser : answers) {
if (anwser.isJsonObject()
diff --git a/core/src/main/java/de/bstly/we/controller/UserController.java b/core/src/main/java/de/bstly/we/controller/UserController.java
index 0ad42d8..0864519 100755
--- a/core/src/main/java/de/bstly/we/controller/UserController.java
+++ b/core/src/main/java/de/bstly/we/controller/UserController.java
@@ -143,7 +143,7 @@ public class UserController extends BaseController {
}
if (!register) {
- throw new EntityResponseStatusException(HttpStatus.UNAUTHORIZED);
+ throw new EntityResponseStatusException(HttpStatus.LOCKED);
}
userModelValidator.validate(userModel, errors);
diff --git a/core/src/main/java/de/bstly/we/controller/support/TokenSessionManager.java b/core/src/main/java/de/bstly/we/controller/support/TokenSessionManager.java
index 91dab66..41c29c1 100644
--- a/core/src/main/java/de/bstly/we/controller/support/TokenSessionManager.java
+++ b/core/src/main/java/de/bstly/we/controller/support/TokenSessionManager.java
@@ -100,7 +100,7 @@ public class TokenSessionManager {
}
permissions.addAll(permissionManager.getForItem(userId, item,
- orderPosition.get("answers").getAsJsonArray(), null, null));
+ orderPosition.get("answers").getAsJsonArray(),lastPaymentDate, null));
}
} catch (Exception e) {
// ignore
@@ -180,7 +180,7 @@ public class TokenSessionManager {
}
permissionManager.applyItem(userId, item,
- position.get("answers").getAsJsonArray(), null, null);
+ position.get("answers").getAsJsonArray(), lastPaymentDate, null);
permissionMappings.addAll(permissionMappingManager.getAllByItem(item));
quotaManager.applyItem(userId, item);
quotaMappings.addAll(quotaMappingManager.getAllByItem(item));
diff --git a/core/src/main/java/de/bstly/we/security/handler/FormAuthenticationSuccessHandler.java b/core/src/main/java/de/bstly/we/security/handler/FormAuthenticationSuccessHandler.java
index 95959c1..22db00d 100644
--- a/core/src/main/java/de/bstly/we/security/handler/FormAuthenticationSuccessHandler.java
+++ b/core/src/main/java/de/bstly/we/security/handler/FormAuthenticationSuccessHandler.java
@@ -18,6 +18,7 @@ import org.springframework.util.Assert;
import com.google.common.collect.Lists;
+import de.bstly.we.controller.support.TokenSessionManager;
import de.bstly.we.security.token.LocalSecondFactorAuthenticationToken;
/**
@@ -28,6 +29,8 @@ public class FormAuthenticationSuccessHandler
@Autowired
protected RememberMeServices rememberMeServices;
+ @Autowired
+ protected TokenSessionManager tokenSessionManager;
private String totpRedirectUrl;
private String rememberMeParameter;
@@ -61,7 +64,7 @@ public class FormAuthenticationSuccessHandler
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
-
+
if (!authentication.isAuthenticated()
&& authentication instanceof PreAuthenticatedAuthenticationToken) {
rememberMeServices.loginFail(request, response);
diff --git a/core/src/main/java/de/bstly/we/security/handler/RestAuthenticationSuccessHandler.java b/core/src/main/java/de/bstly/we/security/handler/RestAuthenticationSuccessHandler.java
index bb69649..b1f6dc4 100644
--- a/core/src/main/java/de/bstly/we/security/handler/RestAuthenticationSuccessHandler.java
+++ b/core/src/main/java/de/bstly/we/security/handler/RestAuthenticationSuccessHandler.java
@@ -31,7 +31,7 @@ public class RestAuthenticationSuccessHandler extends FormAuthenticationSuccessH
*/
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
- Authentication authentication) throws IOException, ServletException {
+ Authentication authentication) throws IOException, ServletException {
if (!authentication.isAuthenticated()) {
rememberMeServices.loginFail(request, response);
response.sendError(HttpStatus.PRECONDITION_REQUIRED.value(),
diff --git a/membership/src/main/java/de/bstly/we/membership/businesslogic/MembershipManager.java b/membership/src/main/java/de/bstly/we/membership/businesslogic/MembershipManager.java
index 96415ca..c5f6d19 100644
--- a/membership/src/main/java/de/bstly/we/membership/businesslogic/MembershipManager.java
+++ b/membership/src/main/java/de/bstly/we/membership/businesslogic/MembershipManager.java
@@ -118,8 +118,11 @@ public class MembershipManager {
int membershipId = Integer.valueOf(membershipIdAnswer.get("answer").getAsInt());
if (internalMembershipId == membershipId) {
writeMembershipId = false;
- logger.trace("Order '" + orderPosition.get("order").getAsString()
- + "' already processed, membership id: '" + membershipId + "'");
+ logger.trace("Order '"
+ + orderPosition.get("order").getAsString()
+ + "' already processed, membership id: '"
+ + membershipId
+ + "'");
}
}
@@ -137,9 +140,10 @@ public class MembershipManager {
JsonObject payload = new JsonObject();
payload.add("answers", answers);
- logger.debug(
- "Write membershipId for '" + orderPosition.get("order").getAsString()
- + "': " + internalMembershipId);
+ logger.debug("Write membershipId for '"
+ + orderPosition.get("order").getAsString()
+ + "': "
+ + internalMembershipId);
pretixManager.request(
String.format("/api/v1/organizers/%s/events/%s/orderpositions/%s/",
@@ -178,8 +182,10 @@ public class MembershipManager {
payload.add("answers", answers);
- logger.debug("Create membershipId for '" + orderPosition.get("order").getAsString()
- + "': " + nextMembershipId);
+ logger.debug("Create membershipId for '"
+ + orderPosition.get("order").getAsString()
+ + "': "
+ + nextMembershipId);
pretixManager
.request(
@@ -261,7 +267,8 @@ public class MembershipManager {
if (membershipId == 0) {
logger.warn("No membership number found for '"
- + membershipOrderPosition.get("order").getAsString() + "'!");
+ + membershipOrderPosition.get("order").getAsString()
+ + "'!");
continue;
}
@@ -270,7 +277,8 @@ public class MembershipManager {
if (membershipStart == null) {
logger.warn("No last payment found for '"
- + membershipOrderPosition.get("order").getAsString() + "'!");
+ + membershipOrderPosition.get("order").getAsString()
+ + "'!");
continue;
}
@@ -307,11 +315,13 @@ public class MembershipManager {
HttpMethod.PATCH, payload);
logger.debug("Write active state for '"
- + membershipOrderPosition.get("order").getAsString() + "': "
+ + membershipOrderPosition.get("order").getAsString()
+ + "': "
+ activeAnswer);
} else {
logger.trace("Order active state for '"
- + membershipOrderPosition.get("order").getAsString() + "' already set: "
+ + membershipOrderPosition.get("order").getAsString()
+ + "' already set: "
+ activeAnswer);
}
}
@@ -383,8 +393,11 @@ public class MembershipManager {
.isBefore(Instant.now())) {
expireMemberships.add(membershipOrderPosition);
} else {
- logger.trace("Membership '" + membershipOrderPosition.get("order").getAsString()
- + "' not expiring in next " + membershipfeeOrderDays + " days.");
+ logger.trace("Membership '"
+ + membershipOrderPosition.get("order").getAsString()
+ + "' not expiring in next "
+ + membershipfeeOrderDays
+ + " days.");
}
}
@@ -428,7 +441,8 @@ public class MembershipManager {
if (membershipId == 0) {
logger.warn("No membership number found for '"
- + membershipOrderPosition.get("order").getAsString() + "'!");
+ + membershipOrderPosition.get("order").getAsString()
+ + "'!");
continue;
}
@@ -445,7 +459,7 @@ public class MembershipManager {
JsonObject membershipFeeOrderPosition = new JsonObject();
membershipFeeOrderPosition.addProperty("item", membershipFeeItemId);
-
+
JsonArray membershipFeeOrderPositionAnswers = new JsonArray();
JsonObject membershipFeeReferenceAnswer = new JsonObject();
membershipFeeReferenceAnswer.addProperty("question",
@@ -454,13 +468,13 @@ public class MembershipManager {
membershipFeeReferenceAnswer.add("option_identifiers", new JsonArray());
membershipFeeReferenceAnswer.addProperty("answer", membershipId);
membershipFeeOrderPositionAnswers.add(membershipFeeReferenceAnswer);
-
+
JsonObject membershipFeeCodeAnswer = new JsonObject();
- membershipFeeCodeAnswer.addProperty("question",
- membershipFeeCodeQuestion);
+ membershipFeeCodeAnswer.addProperty("question", membershipFeeCodeQuestion);
membershipFeeCodeAnswer.add("options", new JsonArray());
membershipFeeCodeAnswer.add("option_identifiers", new JsonArray());
- membershipFeeCodeAnswer.addProperty("answer", membershipOrderPosition.get("order").getAsString());
+ membershipFeeCodeAnswer.addProperty("answer",
+ membershipOrderPosition.get("order").getAsString());
membershipFeeOrderPositionAnswers.add(membershipFeeCodeAnswer);
membershipFeeOrderPosition.add("answers", membershipFeeOrderPositionAnswers);
@@ -477,6 +491,12 @@ public class MembershipManager {
membershipFeeOrder.add("payment_provider", payment.get("provider"));
}
+ Instant expires = InstantHelper.minus(InstantHelper.truncate(
+ InstantHelper.plus(Instant.now(), 1, ChronoUnit.YEARS), ChronoUnit.YEARS),
+ 1, ChronoUnit.DAYS);
+
+ membershipFeeOrder.addProperty("expires",
+ pretixDateFormat.format(Date.from(expires)));
membershipFeeOrder.addProperty("send_email", orderSendmail);
membershipFeeOrder.addProperty("testmode", orderTestmode);
membershipFeeOrder.addProperty("simulate", orderSimulate);
@@ -484,14 +504,12 @@ public class MembershipManager {
membershipFeeOrder = pretixManager.createOrder(membershipFeeOrder);
JsonObject expire = new JsonObject();
- Instant expires = InstantHelper.minus(InstantHelper.truncate(
- InstantHelper.plus(Instant.now(), 1, ChronoUnit.YEARS), ChronoUnit.YEARS),
- 1, ChronoUnit.DAYS);
expire.addProperty("expires", pretixDateFormat.format(Date.from(expires)));
membershipFeeOrder = pretixManager
.extendOrder(membershipFeeOrder.get("code").getAsString(), expire);
- logger.debug("Create membership fee order: " + membershipFeeOrder.toString());
+ logger.debug("Create membership fee order: "
+ + membershipFeeOrder.toString());
} else
// send reminder mail for membership fee order
if (membershipfeeReminderDays > 0 && membershipfeeReminderQuestion > 0
@@ -687,7 +705,8 @@ public class MembershipManager {
active = date.toInstant();
} catch (ParseException e) {
logger.error("Error on parsing active date for '"
- + orderPosition.get("order").getAsString() + "'!", e);
+ + orderPosition.get("order").getAsString()
+ + "'!", e);
}
}
}
@@ -810,7 +829,9 @@ public class MembershipManager {
return pretixDateFormat.parse(answer.get("answer").getAsString()).toInstant();
} catch (ParseException e) {
logger.error("Error on parsing active date for '"
- + orderPosition.get("order").getAsString() + "' in question '" + question
+ + orderPosition.get("order").getAsString()
+ + "' in question '"
+ + question
+ "'!", e);
}
}
diff --git a/pom.xml b/pom.xml
index 3b6bccf..cf68a00 100755
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
UTF-8
11
- 1.3.2-SNAPSHOT
+ 1.4.0-SNAPSHOT