com.parse
Class ParseUser

Object
  extended by com.parse.ParseObject
      extended by com.parse.ParseUser

public class ParseUser
extends ParseObject


Field Summary
 
Fields inherited from class com.parse.ParseObject
DEFAULT_PIN
 
Constructor Summary
ParseUser()
          Constructs a new ParseUser with no data in it.
 
Method Summary
static ParseUser become(String sessionToken)
          Authorize a user with a session token.
static bolts.Task<ParseUser> becomeInBackground(String sessionToken)
          Authorize a user with a session token.
static void becomeInBackground(String sessionToken, LogInCallback callback)
          Authorize a user with a session token.
static void enableAutomaticUser()
          Enables automatic creation of anonymous users.
 ParseUser fetch()
          Fetches this object with the data from the server.
 ParseUser fetchIfNeeded()
          If this ParseObject has not been fetched (i.e.
static ParseUser getCurrentUser()
          This retrieves the currently logged in ParseUser with a valid session, either from memory or disk if necessary.
 String getEmail()
          Retrieves the email address.
static ParseQuery<ParseUser> getQuery()
          Constructs a query for ParseUsers.
 String getSessionToken()
          Retrieves the session token for a user, if they are logged in.
 String getUsername()
          Retrieves the username.
 boolean isAuthenticated()
          Whether the ParseUser has been authenticated on this device.
 boolean isNew()
          Indicates whether this ParseUser was created during this session through a call to ParseUser.signUp() or by logging in with a linked service such as Facebook.
static ParseUser logIn(String username, String password)
          Logs in a user with a username and password.
static bolts.Task<ParseUser> logInInBackground(String username, String password)
          Logs in a user with a username and password.
static void logInInBackground(String username, String password, LogInCallback callback)
          Logs in a user with a username and password.
static void logOut()
          Logs out the currently logged in user session.
 void put(String key, Object value)
          Add a key-value pair to this object.
 void remove(String key)
          Removes a key from this object's data if it exists.
static void requestPasswordReset(String email)
          Requests a password reset email to be sent to the specified email address associated with the user account.
static bolts.Task<Void> requestPasswordResetInBackground(String email)
          Requests a password reset email to be sent in a background thread to the specified email address associated with the user account.
static void requestPasswordResetInBackground(String email, RequestPasswordResetCallback callback)
          Requests a password reset email to be sent in a background thread to the specified email address associated with the user account.
 void setEmail(String email)
          Sets the email address.
 void setPassword(String password)
          Sets the password.
 void setUsername(String username)
          Sets the username.
 void signUp()
          Signs up a new user.
 bolts.Task<Void> signUpInBackground()
          Signs up a new user.
 void signUpInBackground(SignUpCallback callback)
          Signs up a new user.
 
Methods inherited from class com.parse.ParseObject
add, addAll, addAllUnique, addUnique, containsKey, create, create, createWithoutData, createWithoutData, delete, deleteAll, deleteAllInBackground, deleteAllInBackground, deleteEventually, deleteEventually, deleteInBackground, deleteInBackground, fetchAll, fetchAllIfNeeded, fetchAllIfNeededInBackground, fetchAllIfNeededInBackground, fetchAllInBackground, fetchAllInBackground, fetchFromLocalDatastore, fetchFromLocalDatastoreInBackground, fetchIfNeededInBackground, fetchIfNeededInBackground, fetchInBackground, fetchInBackground, get, getACL, getBoolean, getBytes, getClassName, getCreatedAt, getDate, getDouble, getInt, getJSONArray, getJSONObject, getList, getLong, getMap, getNumber, getObjectId, getParseFile, getParseGeoPoint, getParseObject, getParseUser, getRelation, getString, getUpdatedAt, has, hasSameId, increment, increment, isDataAvailable, isDirty, isDirty, keySet, pin, pin, pinAll, pinAll, pinAllInBackground, pinAllInBackground, pinAllInBackground, pinAllInBackground, pinInBackground, pinInBackground, pinInBackground, pinInBackground, refresh, refreshInBackground, registerSubclass, removeAll, save, saveAll, saveAllInBackground, saveAllInBackground, saveEventually, saveEventually, saveInBackground, saveInBackground, setACL, setObjectId, unpin, unpin, unpinAll, unpinAll, unpinAll, unpinAll, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinInBackground, unpinInBackground, unpinInBackground, unpinInBackground
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseUser

public ParseUser()
Constructs a new ParseUser with no data in it. A ParseUser constructed in this way will not have an objectId and will not persist to the database until ParseUser.signUp() is called.

Method Detail

isAuthenticated

public boolean isAuthenticated()
Whether the ParseUser has been authenticated on this device. This will be true if the ParseUser was obtained via a logIn or signUp method. Only an authenticated ParseUser can be saved (with altered attributes) and deleted.


remove

public void remove(String key)
Description copied from class: ParseObject
Removes a key from this object's data if it exists.

Overrides:
remove in class ParseObject
Parameters:
key - The key to remove.

setUsername

public void setUsername(String username)
Sets the username. Usernames cannot be null or blank.

Parameters:
username - The username to set.

getUsername

public String getUsername()
Retrieves the username.


setPassword

public void setPassword(String password)
Sets the password.

Parameters:
password - The password to set.

setEmail

public void setEmail(String email)
Sets the email address.

Parameters:
email - The email address to set.

getEmail

public String getEmail()
Retrieves the email address.


put

public void put(String key,
                Object value)
Description copied from class: ParseObject
Add a key-value pair to this object. It is recommended to name keys in partialCamelCaseLikeThis.

Overrides:
put in class ParseObject
Parameters:
key - Keys must be alphanumerical plus underscore, and start with a letter.
value - Values may be numerical, String, JSONObject, JSONArray, JSONObject.NULL, or other ParseObjects. value may not be null.

getSessionToken

public String getSessionToken()
Retrieves the session token for a user, if they are logged in.


fetch

public ParseUser fetch()
                throws ParseException
Description copied from class: ParseObject
Fetches this object with the data from the server. Call this whenever you want the state of the object to reflect exactly what is on the server.

Overrides:
fetch in class ParseObject
Returns:
The ParseObject that was fetched.
Throws:
ParseException - Throws an exception if the server is inaccessible.

signUpInBackground

public bolts.Task<Void> signUpInBackground()
Signs up a new user. You should call this instead of ParseObject.save() for new ParseUsers. This will create a new ParseUser on the server, and also persist the session on disk so that you can access the user using ParseUser.getCurrentUser().

A username and password must be set before calling signUp.

This is preferable to using ParseUser.signUp(), unless your code is already running from a background thread.

Returns:
A Task that is resolved when sign up completes.

signUp

public void signUp()
            throws ParseException
Signs up a new user. You should call this instead of ParseObject.save() for new ParseUsers. This will create a new ParseUser on the server, and also persist the session on disk so that you can access the user using ParseUser.getCurrentUser().

A username and password must be set before calling signUp.

Typically, you should use ParseUser.signUpInBackground() instead of this, unless you are managing your own threading.

Throws:
ParseException - Throws an exception if the server is inaccessible, or if the username has already been taken.

signUpInBackground

public void signUpInBackground(SignUpCallback callback)
Signs up a new user. You should call this instead of ParseObject.save() for new ParseUsers. This will create a new ParseUser on the server, and also persist the session on disk so that you can access the user using ParseUser.getCurrentUser().

A username and password must be set before calling signUp.

This is preferable to using ParseUser.signUp(), unless your code is already running from a background thread.

Parameters:
callback - callback.done(user, e) is called when the signUp completes.

logInInBackground

public static bolts.Task<ParseUser> logInInBackground(String username,
                                                      String password)
Logs in a user with a username and password. On success, this saves the session to disk, so you can retrieve the currently logged in user using ParseUser.getCurrentUser().

This is preferable to using ParseUser.logIn(java.lang.String, java.lang.String), unless your code is already running from a background thread.

Parameters:
username - The username to log in with.
password - The password to log in with.
Returns:
A Task that is resolved when logging in completes.

logIn

public static ParseUser logIn(String username,
                              String password)
                       throws ParseException
Logs in a user with a username and password. On success, this saves the session to disk, so you can retrieve the currently logged in user using ParseUser.getCurrentUser().

Typically, you should use ParseUser.logInInBackground(java.lang.String, java.lang.String) instead of this, unless you are managing your own threading.

Parameters:
username - The username to log in with.
password - The password to log in with.
Returns:
The user if the login was successful.
Throws:
ParseException - Throws an exception if the login was unsuccessful.

logInInBackground

public static void logInInBackground(String username,
                                     String password,
                                     LogInCallback callback)
Logs in a user with a username and password. On success, this saves the session to disk, so you can retrieve the currently logged in user using ParseUser.getCurrentUser().

This is preferable to using ParseUser.logIn(java.lang.String, java.lang.String), unless your code is already running from a background thread.

Parameters:
username - The username to log in with.
password - The password to log in with.
callback - callback.done(user, e) is called when the login completes.

becomeInBackground

public static bolts.Task<ParseUser> becomeInBackground(String sessionToken)
Authorize a user with a session token. On success, this saves the session to disk, so you can retrieve the currently logged in user using ParseUser.getCurrentUser().

This is preferable to using ParseUser.become(java.lang.String), unless your code is already running from a background thread.

Parameters:
sessionToken - The session token to authorize with.
Returns:
A Task that is resolved when authorization completes.

become

public static ParseUser become(String sessionToken)
                        throws ParseException
Authorize a user with a session token. On success, this saves the session to disk, so you can retrieve the currently logged in user using ParseUser.getCurrentUser().

Typically, you should use ParseUser.becomeInBackground(java.lang.String) instead of this, unless you are managing your own threading.

Parameters:
sessionToken - The session token to authorize with.
Returns:
The user if the authorization was successful.
Throws:
ParseException - Throws an exception if the authorization was unsuccessful.

becomeInBackground

public static void becomeInBackground(String sessionToken,
                                      LogInCallback callback)
Authorize a user with a session token. On success, this saves the session to disk, so you can retrieve the currently logged in user using ParseUser.getCurrentUser().

This is preferable to using ParseUser.become(java.lang.String), unless your code is already running from a background thread.

Parameters:
sessionToken - The session token to authorize with.
callback - callback.done(user, e) is called when the authorization completes.

getCurrentUser

public static ParseUser getCurrentUser()
This retrieves the currently logged in ParseUser with a valid session, either from memory or disk if necessary.

Returns:
The currently logged in ParseUser

logOut

public static void logOut()
Logs out the currently logged in user session. This will remove the session from disk, log out of linked services, and future calls to ParseUser.getCurrentUser() will return null.


requestPasswordResetInBackground

public static bolts.Task<Void> requestPasswordResetInBackground(String email)
Requests a password reset email to be sent in a background thread to the specified email address associated with the user account. This email allows the user to securely reset their password on the Parse site.

This is preferable to using ParseUser.requestPasswordReset(String), unless your code is already running from a background thread.

Parameters:
email - The email address associated with the user that forgot their password.
Returns:
A Task that is resolved when the command completes.

requestPasswordReset

public static void requestPasswordReset(String email)
                                 throws ParseException
Requests a password reset email to be sent to the specified email address associated with the user account. This email allows the user to securely reset their password on the Parse site.

Typically, you should use ParseUser.requestPasswordResetInBackground(java.lang.String) instead of this, unless you are managing your own threading.

Parameters:
email - The email address associated with the user that forgot their password.
Throws:
ParseException - Throws an exception if the server is inaccessible, or if an account with that email doesn't exist.

requestPasswordResetInBackground

public static void requestPasswordResetInBackground(String email,
                                                    RequestPasswordResetCallback callback)
Requests a password reset email to be sent in a background thread to the specified email address associated with the user account. This email allows the user to securely reset their password on the Parse site.

This is preferable to using ParseUser.requestPasswordReset(String), unless your code is already running from a background thread.

Parameters:
email - The email address associated with the user that forgot their password.
callback - callback.done(e) is called when the request completes.

fetchIfNeeded

public ParseUser fetchIfNeeded()
                        throws ParseException
Description copied from class: ParseObject
If this ParseObject has not been fetched (i.e. ParseObject.isDataAvailable() returns false), fetches this object with the data from the server.

Overrides:
fetchIfNeeded in class ParseObject
Returns:
The fetched ParseObject.
Throws:
ParseException - Throws an exception if the server is inaccessible.

isNew

public boolean isNew()
Indicates whether this ParseUser was created during this session through a call to ParseUser.signUp() or by logging in with a linked service such as Facebook.


enableAutomaticUser

public static void enableAutomaticUser()
Enables automatic creation of anonymous users. After calling this method, ParseUser.getCurrentUser() will always have a value. The user will only be created on the server once the user has been saved, or once an object with a relation to that user or an ACL that refers to the user has been saved. Note: saveEventually will not work if an item being saved has a relation to an automatic user that has never been saved.


getQuery

public static ParseQuery<ParseUser> getQuery()
Constructs a query for ParseUsers.