Skip to content
Snippets Groups Projects
Commit e366c823 authored by Jawnnypoo's avatar Jawnnypoo
Browse files

Show the error message on a 401, since it could be that they have 2FA enabled

parent 8b1d8af4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -28,6 +28,7 @@ import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.TextView;
 
import com.bluelinelabs.logansquare.LoganSquare;
import com.commit451.gitlab.App;
import com.commit451.gitlab.BuildConfig;
import com.commit451.gitlab.R;
Loading
Loading
@@ -39,6 +40,7 @@ import com.commit451.gitlab.dialog.HttpLoginDialog;
import com.commit451.gitlab.event.LoginEvent;
import com.commit451.gitlab.event.ReloadDataEvent;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.model.api.Message;
import com.commit451.gitlab.model.api.UserFull;
import com.commit451.gitlab.model.api.UserLogin;
import com.commit451.gitlab.navigation.Navigator;
Loading
Loading
@@ -48,6 +50,7 @@ import com.commit451.gitlab.ssl.X509CertificateException;
import com.commit451.gitlab.ssl.X509Util;
import com.commit451.teleprinter.Teleprinter;
 
import java.io.IOException;
import java.net.ConnectException;
import java.security.cert.CertificateEncodingException;
import java.util.ArrayList;
Loading
Loading
@@ -516,7 +519,16 @@ public class LoginActivity extends BaseActivity {
handleBasicAuthentication(response);
return;
}
Snackbar.make(mRoot, getString(R.string.login_unauthorized), Snackbar.LENGTH_LONG)
String errorMessage = getString(R.string.login_unauthorized);
try {
Message message = LoganSquare.parse(response.errorBody().byteStream(), Message.class);
if (message != null && message.getMessage() != null) {
errorMessage = message.getMessage();
}
} catch (IOException e) {
Timber.e(e);
}
Snackbar.make(mRoot, errorMessage, Snackbar.LENGTH_LONG)
.show();
return;
case 404:
Loading
Loading
package com.commit451.gitlab.model.api;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* The structure for a message from the server, which is usually found in a response body
*/
@JsonObject
public class Message {
@JsonField(name = "message")
String mMessage;
public String getMessage() {
return mMessage;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment