fix User#addFlag and User#hasFlag
This commit is contained in:
parent
f3d5ead017
commit
78b7e1a61a
@ -17,6 +17,7 @@ public final class EnvironmentUtils {
|
||||
* Is the app running in a "cloud" environment?
|
||||
*/
|
||||
@Getter private static final boolean cloud;
|
||||
|
||||
static {
|
||||
String appEnv = System.getenv("APP_ENV");
|
||||
String cloudEnv = System.getenv("APP_CLOUD");
|
||||
|
@ -75,7 +75,7 @@ public final class User {
|
||||
* @param flag the flag to add
|
||||
*/
|
||||
public void addFlag(@NonNull UserFlag flag) {
|
||||
flags |= flag.ordinal();
|
||||
flags |= flag.bitwise();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,6 +85,7 @@ public final class User {
|
||||
* @return whether this user has the flag
|
||||
*/
|
||||
public boolean hasFlag(@NonNull UserFlag flag) {
|
||||
return (flags & flag.ordinal()) != 0;
|
||||
int bitwise = flag.bitwise();
|
||||
return (flags & bitwise) == bitwise;
|
||||
}
|
||||
}
|
@ -11,6 +11,11 @@ public enum UserFlag {
|
||||
*/
|
||||
DISABLED,
|
||||
|
||||
/**
|
||||
* The user's email has been verified.
|
||||
*/
|
||||
EMAIL_VERIFIED,
|
||||
|
||||
/**
|
||||
* The user completed the onboarding process.
|
||||
*/
|
||||
@ -24,5 +29,14 @@ public enum UserFlag {
|
||||
/**
|
||||
* The user is an administrator.
|
||||
*/
|
||||
ADMINISTRATOR
|
||||
ADMINISTRATOR;
|
||||
|
||||
/**
|
||||
* Get the bitwise value of this flag.
|
||||
*
|
||||
* @return the bitwise value
|
||||
*/
|
||||
public int bitwise() {
|
||||
return 1 << ordinal();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user