feat: add club member's gestion page
This commit is contained in:
25
src/main/java/fr/titionfire/ffsaf/utils/GroupeUtils.java
Normal file
25
src/main/java/fr/titionfire/ffsaf/utils/GroupeUtils.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package fr.titionfire.ffsaf.utils;
|
||||
|
||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
|
||||
public class GroupeUtils {
|
||||
public static boolean isInClubGroup(long id, JsonWebToken accessToken) {
|
||||
if (accessToken.getClaim("user_groups") instanceof Iterable<?>) {
|
||||
for (Object str : (Iterable<?>) accessToken.getClaim("user_groups")) {
|
||||
if (str.toString().substring(1, str.toString().length() - 1).startsWith("/club/" + id + "-"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean contains(String string, JsonWebToken accessToken) {
|
||||
if (accessToken.getClaim("user_groups") instanceof Iterable<?>) {
|
||||
for (Object str : (Iterable<?>) accessToken.getClaim("user_groups")) {
|
||||
if (str.toString().substring(1, str.toString().length() - 1).contains(string))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,17 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public enum RoleAsso {
|
||||
MEMBRE("Membre"),
|
||||
PRESIDENT("Président"),
|
||||
TRESORIER("Trésorier"),
|
||||
SECRETAIRE("Secrétaire");
|
||||
MEMBRE("Membre", 0),
|
||||
PRESIDENT("Président", 3),
|
||||
TRESORIER("Trésorier", 1),
|
||||
SECRETAIRE("Secrétaire", 2);
|
||||
|
||||
public String name;
|
||||
public final String name;
|
||||
public final int level;
|
||||
|
||||
RoleAsso(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
RoleAsso(String name, int level) {
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
22
src/main/java/fr/titionfire/ffsaf/utils/Utils.java
Normal file
22
src/main/java/fr/titionfire/ffsaf/utils/Utils.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package fr.titionfire.ffsaf.utils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static int getSaison() {
|
||||
return getSaison(new Date());
|
||||
}
|
||||
|
||||
public static int getSaison(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
|
||||
if (calendar.get(Calendar.MONTH) >= Calendar.SEPTEMBER) {
|
||||
return calendar.get(Calendar.YEAR);
|
||||
} else {
|
||||
return calendar.get(Calendar.YEAR) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user