Package net.minheur.potoflux.login
Class ConnectionHandler
java.lang.Object
net.minheur.potoflux.login.ConnectionHandler
Handles all things related to connecting you to your account, disconnecting you, and keeping your
It synchronizes multiple other classes to do so
accountIt synchronizes multiple other classes to do so
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic AccountAccount of the user currently connectedstatic booleanEasy access to the account self-creation autorisationstatic boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaccountFor(String token) Logs in with a token.static voidIf there's a token stored in the system, sends a request to remove it on the server.
Weather it succeeds of fails, will clear local tokenstatic Perms[]static Stringstatic StringSends a request to the server, getting a connection token for specified IDs
If the connection fails, it will calldisplayLoggingError(LoginResponse)and returnnullstatic voidlogin()Displays a connection dialog, then if confirmed logout() thenlogWith(String, String)static voidlogout()static voidLogs in with an email and a password.
Done when the user connects / reconnects to its account using its IDsstatic voidRunslogout()ifisLoggedistrue, else callslogin().
Once the right one is run, follows byreloadAuthUi()static voidSends a request, getting / regetting weather the account creation is allowedstatic voidReloads UI related to account statestatic voidsendAccountCreationLockRequest(boolean isAllowed) Sends a request to allow or not the creation of account
-
Field Details
-
account
Account of the user currently connected -
isLogged
public static boolean isLogged -
isAccountCreationEnabled
public static boolean isAccountCreationEnabledEasy access to the account self-creation autorisation
-
-
Constructor Details
-
ConnectionHandler
public ConnectionHandler()
-
-
Method Details
-
logWith
Logs in with an email and a password.
Done when the user connects / reconnects to its account using its IDs- Parameters:
email- of the userpassword- of the account
-
accountFor
Logs in with a token. CallsdisplayInfoError(InfoResponse)if the authentication fails
Used when auto-logging on startup- Parameters:
token- actually stored for the account
-
fillPerms
Helper that transform aStringarray (SQL codes) into aPermsarray
If a code isn't known, it gets ignored- Parameters:
perms- array of SQL codes sent by the database- Returns:
- the array of
Permscorresponding the SQL codes.
-
getToken
Sends a request to the server, getting a connection token for specified IDs
If the connection fails, it will calldisplayLoggingError(LoginResponse)and returnnull- Parameters:
email- of the target accountpassword- of the account- Returns:
- the token sent by the database or
nullif failed
-
reloadAccountCreationPermission
public static void reloadAccountCreationPermission()Sends a request, getting / regetting weather the account creation is allowed -
sendAccountCreationLockRequest
public static void sendAccountCreationLockRequest(boolean isAllowed) Sends a request to allow or not the creation of account- Parameters:
isAllowed- weather account self-creation is allowed
-
checkAndRemoveExistingToken
public static void checkAndRemoveExistingToken()If there's a token stored in the system, sends a request to remove it on the server.
Weather it succeeds of fails, will clear local token -
performAuthAction
public static void performAuthAction()Runslogout()ifisLoggedistrue, else callslogin().
Once the right one is run, follows byreloadAuthUi() -
reloadAuthUi
public static void reloadAuthUi()Reloads UI related to account state -
logout
public static void logout() -
login
public static void login()Displays a connection dialog, then if confirmed logout() thenlogWith(String, String) -
getAuthButtonStatus
- Returns:
- the correct text for the auth buttton
-