com.leanengine
Class LeanAccount

java.lang.Object
  extended by com.leanengine.LeanAccount

public class LeanAccount
extends java.lang.Object


Constructor Summary
protected LeanAccount(java.lang.Long id, java.lang.String nickName, java.lang.String providerId, java.lang.String provider, java.util.Map<java.lang.String,java.lang.Object> providerProperties)
           
 
Method Summary
static LeanAccount getAccountData()
          Gets current user account.
 java.lang.Long getId()
          Returns the internal Id of the account.
 java.lang.String getNickName()
          Nickname of the user represented by this account.
 java.lang.String getProvider()
          Returns the identification string of authentication provider that authenticated this account.
 java.lang.String getProviderId()
          User ID as provided by authentication provider.
 java.util.Map<java.lang.String,java.lang.Object> getProviderProperties()
          Returns provider-dependent map of user properties.
static boolean isUserLoggedIn()
          Checks if user is logged in.
static java.lang.Boolean logout()
          Logs user out of server.
static void logoutInBackground(NetworkCallback<java.lang.Boolean> callback)
          Logs user out of server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeanAccount

protected LeanAccount(java.lang.Long id,
                      java.lang.String nickName,
                      java.lang.String providerId,
                      java.lang.String provider,
                      java.util.Map<java.lang.String,java.lang.Object> providerProperties)
Method Detail

logout

public static java.lang.Boolean logout()
                                throws LeanException
Logs user out of server. Current authentication tokens are removed on server and on client.

Returns:
Returns true if user was logged in and was logged out successfully.
Throws:
LeanException

logoutInBackground

public static void logoutInBackground(NetworkCallback<java.lang.Boolean> callback)
Logs user out of server. Current authentication tokens are removed on server and on client. Runs on the background thread.

Parameters:
callback - Callback to be invoked when logout finishes.
Throws:
LeanException

isUserLoggedIn

public static boolean isUserLoggedIn()
Checks if user is logged in.

Returns:
Returns true if user is logged in, false otherwise.

getAccountData

public static LeanAccount getAccountData()
                                  throws LeanException
Gets current user account.

Returns:
LeanAccount of the currently logged-in user.
Throws:
LeanException

getId

public java.lang.Long getId()
Returns the internal Id of the account. Account Id is server generated and is unique per account.

Returns:
Id of the account.

getProviderId

public java.lang.String getProviderId()
User ID as provided by authentication provider. Ids are guaranteed to be unique within provider, but not across different providers.

Returns:
User ID generated by authentication provider.

getProvider

public java.lang.String getProvider()
Returns the identification string of authentication provider that authenticated this account.

Identification string may contain only provider unique string, e.g. 'fb-oauth' for Facebook, or it might contain full URL including user identification, e.g. 'https://www.google.com/accounts/o8/id?id=user_id_hash' in case of Google OpenID.

Returns:
Provider authentication string.

getNickName

public java.lang.String getNickName()
Nickname of the user represented by this account. Format is provider dependent. Some providers use email as nick name.

Returns:
Nickname.

getProviderProperties

public java.util.Map<java.lang.String,java.lang.Object> getProviderProperties()
Returns provider-dependent map of user properties. This may contain data such as gender, first name, last name, etc..

Returns:
Map of properties.