fix token redeem
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
+4
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user