/** * 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 {@link #getCurrentUser}. * <p/> * Typically, you should use {@link #logInInBackground} instead of this, unless you are managing * your own threading. * * @param username The username to log in with. * @param password The password to log in with. * @return The user if the login was successful. * @throws ParseException Throws an exception if the login was unsuccessful. */ public static ParseUser logIn(String username, String password) throws ParseException { return ParseTaskUtils.wait(logInInBackground(username, 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 {@link #getCurrentUser}. * <p/> * This is preferable to using {@link #logIn}, unless your code is already running from a * background thread. * * @param username The username to log in with. * @param password The password to log in with. * @param callback callback.done(user, e) is called when the login completes. */ public static void logInInBackground(final String username, final String password, LogInCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(logInInBackground(username, password), callback); }
@Test public void testLogInWithNoPassword() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Must specify a password for the user to log in with"); ParseTaskUtils.wait(ParseUser.logInInBackground("userName", null)); }
@Test public void testLogInInWithNoUserName() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Must specify a username for the user to log in with"); ParseTaskUtils.wait(ParseUser.logInInBackground(null, "password")); }
ParseUser.logInInBackground("userName", "password", new LogInCallback() { @Override public void done(ParseUser user, ParseException e) {
private void ValidateUser(String username, String pwd) { ParseUser.logInInBackground(username, pwd, new LogInCallback() { public void done(final ParseUser user, ParseException e) { if (user != null) {
} else { loadingStart(true); ParseUser.logInInBackground(username, password, new LogInCallback() { @Override public void done(ParseUser user, ParseException e) {
@NonNull @CheckReturnValue public static Single<ParseUser> logIn(@NonNull final String username, @NonNull final String password) { return RxTask.single(() -> ParseUser.logInInBackground(username, password)); }