/** * Logs out the currently logged in user session. This will remove the session from disk, log out * of linked services, and future calls to {@link #getCurrentUser()} will return {@code null}. * <p/> * This is preferable to using {@link #logOut}, unless your code is already running from a * background thread. * * @return A Task that is resolved when logging out completes. */ public static Task<Void> logOutInBackground() { return getCurrentUserController().logOutAsync(); }
static Task<ParseUser> getCurrentUserAsync() { return getCurrentUserController().getAsync(); }
public static Task<String> getCurrentSessionTokenAsync() { return getCurrentUserController().getCurrentSessionTokenAsync(); }
private static Task<Void> saveCurrentUserAsync(ParseUser user) { return getCurrentUserController().setAsync(user); }
/** * Used by {@link ParseObject#pin} to persist lazy users to LDS that haven't been pinned yet. */ /* package */ static Task<Void> pinCurrentUserIfNeededAsync(ParseUser user) { if (!Parse.isLocalDatastoreEnabled()) { throw new IllegalStateException("Method requires Local Datastore. " + "Please refer to `Parse#enableLocalDatastore(Context)`."); } return getCurrentUserController().setIfNeededAsync(user); }
/** * This retrieves the currently logged in ParseUser with a valid session, either from memory or * disk if necessary. * * @param shouldAutoCreateUser {@code true} to automatically create and set an anonymous user as current. * @return The currently logged in ParseUser */ private static ParseUser getCurrentUser(boolean shouldAutoCreateUser) { try { return ParseTaskUtils.wait(getCurrentUserController().getAsync(shouldAutoCreateUser)); } catch (ParseException e) { //TODO (grantland): Publicize this exception return null; } }
ParseUser.getCurrentUserController().clearFromMemory(); } else if (className.equals(getClassName(ParseInstallation.class))) { ParseInstallation.getCurrentInstallationController().clearFromMemory();
return getCurrentUserController().getAsync(false).onSuccessTask(new Continuation<ParseUser, Task<ParseUser>>() { @Override public Task<ParseUser> then(Task<ParseUser> task) {
/** * Enables revocable sessions. This method is only required if you wish to use * {@link ParseSession} APIs and do not have revocable sessions enabled in your application * settings on your parse server. * <p/> * Upon successful completion of this {@link Task}, {@link ParseSession} APIs will be available * for use. * * @return A {@link Task} that will resolve when enabling revocable session */ public static Task<Void> enableRevocableSessionInBackground() { // TODO(mengyan): Right now there is no way for us to add interceptor for this client, // so maybe we should move add interceptor steps to restClient() ParseCorePlugins.getInstance().registerUserController( new NetworkUserController(ParsePlugins.get().restClient(), true)); return getCurrentUserController().getAsync(false).onSuccessTask(new Continuation<ParseUser, Task<Void>>() { @Override public Task<Void> then(Task<ParseUser> task) { ParseUser user = task.getResult(); if (user == null) { return Task.forResult(null); } return user.upgradeToRevocableSessionAsync(); } }); }