mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-07 19:42:17 +00:00
Payment: Fix bugs on handling webhook events, add logs
This commit is contained in:
1 parent
2b70ba99bf
commit
b8062a059d
3 files changed
+22
No files matched your search
@@ -118,4 +118,6 @@ public interface User extends SecurityUser<RoleDefinition, Role, UserGroup> {
|
||||
void setSubscriptions(Subscription[] subscriptions);
|
||||
|
||||
Subscription getSubscriptionByPlan(String planId);
|
||||
|
||||
Subscription getSubscriptionById(String subscriptionId);
|
||||
}
|
||||
@@ -400,4 +400,17 @@ public class UserImpl extends SecurityUserImpl<RoleDefinition, Role, UserGroup,
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription getSubscriptionById(String subscriptionId) {
|
||||
if (subscriptionId != null && !subscriptionId.isEmpty() && subscriptions.length > 0) {
|
||||
for (Subscription subscription : subscriptions) {
|
||||
if (subscription.getSubscriptionId() != null
|
||||
&& subscription.getSubscriptionId().equals(subscriptionId)) {
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2535,6 +2535,11 @@ public class SecurityServiceImpl implements ReplicableSecurityService, ClearStat
|
||||
if (user != null) {
|
||||
String newSubscriptionPlanId = newSubscription.getPlanId();
|
||||
Subscription currentSubscription = user.getSubscriptionByPlan(newSubscriptionPlanId);
|
||||
logger.log(Level.INFO, "Update user subscription for plan " + newSubscriptionPlanId);
|
||||
logger.log(Level.INFO, "Current user plan subscription: "
|
||||
+ (currentSubscription != null ? currentSubscription.toString() : "null"));
|
||||
logger.log(Level.INFO,
|
||||
"New plan subscription: " + (newSubscription != null ? newSubscription.toString() : "null"));
|
||||
if (shouldUpdateUserRolesForSubscription(currentSubscription, newSubscription)) {
|
||||
updateUserRolesOnSubscriptionChange(user, currentSubscription, newSubscription);
|
||||
}
|
||||
@@ -2620,6 +2625,7 @@ public class SecurityServiceImpl implements ReplicableSecurityService, ClearStat
|
||||
|
||||
private void removeUserPlanRoles(User user, SubscriptionPlan plan) throws UserManagementException {
|
||||
if (plan != null) {
|
||||
logger.log(Level.INFO, "Remove user roles of subscription plan " + plan.getName());
|
||||
Role[] roles = getSubscriptionPlanUserRoles(user, plan);
|
||||
for (Role role : roles) {
|
||||
store.removeRoleFromUser(user.getName(), role);
|
||||
@@ -2629,6 +2635,7 @@ public class SecurityServiceImpl implements ReplicableSecurityService, ClearStat
|
||||
|
||||
private void addUserPlanRoles(User user, SubscriptionPlan plan) throws UserManagementException {
|
||||
if (plan != null) {
|
||||
logger.log(Level.INFO, "Add user roles for subscription plan " + plan.getName());
|
||||
Role[] roles = getSubscriptionPlanUserRoles(user, plan);
|
||||
for (Role role : roles) {
|
||||
store.addRoleForUser(user.getName(), role);
|
||||
|
||||
Reference in new issue
Block a user