mirror of
https://github.com/etesync/android
synced 2025-06-26 01:42:37 +00:00
Handle failing to connect to server during login.
This commit is contained in:
parent
eb9c3aa907
commit
c33bc0ee19
@ -31,7 +31,7 @@ public class JournalAuthenticator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthToken(String username, String password) throws Exceptions.HttpException {
|
public String getAuthToken(String username, String password) throws Exceptions.HttpException, IOException {
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder()
|
FormBody.Builder formBuilder = new FormBody.Builder()
|
||||||
.add("username", username)
|
.add("username", username)
|
||||||
.add("password", password);
|
.add("password", password);
|
||||||
@ -41,7 +41,6 @@ public class JournalAuthenticator {
|
|||||||
.url(remote)
|
.url(remote)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try {
|
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
return GsonHelper.gson.fromJson(response.body().charStream(), AuthResponse.class).token;
|
return GsonHelper.gson.fromJson(response.body().charStream(), AuthResponse.class).token;
|
||||||
@ -50,10 +49,5 @@ public class JournalAuthenticator {
|
|||||||
} else {
|
} else {
|
||||||
throw new Exceptions.HttpException(response);
|
throw new Exceptions.HttpException(response);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
App.log.log(Level.SEVERE, "Couldn't download external resource", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ package at.bitfire.davdroid.ui.setup;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -59,7 +60,7 @@ public class BaseConfigurationFinder {
|
|||||||
String authtoken = null;
|
String authtoken = null;
|
||||||
try {
|
try {
|
||||||
authtoken = authenticator.getAuthToken(credentials.userName, credentials.password);
|
authtoken = authenticator.getAuthToken(credentials.userName, credentials.password);
|
||||||
} catch (Exceptions.HttpException e) {
|
} catch (Exceptions.HttpException|IOException e) {
|
||||||
log.warning(e.getMessage());
|
log.warning(e.getMessage());
|
||||||
|
|
||||||
failed = true;
|
failed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user