UserHandler

public final class UserHandler

Class that handles user specific task such as login or profile update

Fields

ERROR_TOKEN

public static final String ERROR_TOKEN

Result Token: Error occurred while fetching

FAILED_TOKEN

public static final String FAILED_TOKEN

Result Token: Failed to get

SIGNUP_FAILED

public static final String SIGNUP_FAILED

Sign up result: Sign up failed

SIGNUP_SUCCESS

public static final String SIGNUP_SUCCESS

Sign up result: Sign up successful

SIGNUP_USEREXIST

public static final String SIGNUP_USEREXIST

Sign up result: User already exists

Methods

deleteProfile

public static boolean deleteProfile(String token)

Deletes user profile of the current logged in user

Parameters:
  • token – Session token
Returns:

true if success

getLoginToken

static String getLoginToken(String email, String password, String location)

Fetches token from server and returns it

Parameters:
  • email – User email
  • password – User password
  • location – User location
Returns:

Token string. If error, one of the listed error tokens

getToken

public static String getToken()

Get the current session token

Returns:The current session token. If not possible, one of the listed Error tokens

getUserEmail

public static String getUserEmail()

Gets logged user email

Returns:Logged user email

getUsername

public static String getUsername()

Gets logged user username (id)

Returns:Logged user username

getUsernameFrom

public static String getUsernameFrom(String email)

Returns the standard username from an email

Parameters:
  • email – user Email
Returns:

username

isValidEmail

public static boolean isValidEmail(String email)

Validates email, with the global rules

Parameters:
  • email – Candidate email
Returns:

true if its valid, false otherwise

isValidPassword

public static boolean isValidPassword(String pass)

Validates password, with the global rules

Parameters:
  • pass – Candidate password
Returns:

true if its valid, false otherwise

logout

public static void logout()

Logouts from the current session

sendLike

public static boolean sendLike(String token, String candidateId, boolean liked)

Sends a like/nope from the active user

Parameters:
  • token – session token
  • candidateId – candidate id
  • liked – true if liked, false if not
Returns:

true if success

sendMessage

public static boolean sendMessage(String token, String receiverId, String message)

Sends a message from the active user

Parameters:
  • token – session token
  • receiverId – receiver id
  • message – message to send
Returns:

true if success

signUp

public static String signUp(String email, String password, Map<String, String> userdata)

Creates a new user with the info

Parameters:
  • email – User email
  • password – User password
  • userdata – Map containing userdata as field:value
Returns:

Sign up result (one of the listed results const)

updateInfo

public static boolean updateInfo(String token, Map<String, String> userdata)

Updates user info

Parameters:
  • token – Session token
  • userdata – Map containing userdata as field:value
Returns:

true if success

uploadProfilePicture

public static void uploadProfilePicture(Bitmap profilePicture, String token)

Uploads a new profile picture for the logged in user

Parameters:
  • profilePicture – New picture
  • token – Session token