Commit a69e3f54 authored by Tiago Cunha's avatar Tiago Cunha

Necessary tooling update. Initital setup work for 2FA

parent 94beac85
......@@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
......
......@@ -10,7 +10,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -82,7 +82,13 @@ public class MethodCallHelper {
if (TextUtils.isEmpty(errMessageJson)) {
return Task.forError(exception);
}
String errType = new JSONObject(errMessageJson).getString("error");
String errMessage = new JSONObject(errMessageJson).getString("message");
if (TwoStepAuthException.TYPE.equals(errType)) {
return Task.forError(new TwoStepAuthException(errMessage));
}
return Task.forError(new Exception(errMessage));
} else if (exception instanceof DDPClientCallback.RPC.Error) {
String errMessage = ((DDPClientCallback.RPC.Error) exception).error.getString("message");
......
package chat.rocket.android.api;
public class TwoStepAuthException extends Exception {
public static final String TYPE = "totp-required";
private static final long serialVersionUID = 7063596902054234189L;
public TwoStepAuthException() {
super();
}
public TwoStepAuthException(String message) {
super(message);
}
}
......@@ -15,6 +15,8 @@ public interface LoginContract {
void showError(String message);
void showLoginServices(List<LoginServiceConfiguration> loginServiceList);
void showTwoStepAuth();
}
interface Presenter extends BaseContract.Presenter<View> {
......
......@@ -115,6 +115,11 @@ public class LoginFragment extends AbstractServerConfigFragment implements Login
}
}
@Override
public void showTwoStepAuth() {
//
}
@Override
public void onResume() {
super.onResume();
......
......@@ -8,6 +8,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import bolts.Task;
import chat.rocket.android.BackgroundLooper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.api.TwoStepAuthException;
import chat.rocket.android.helper.Logger;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.shared.BasePresenter;
......@@ -74,7 +75,14 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
.continueWith(task -> {
if (task.isFaulted()) {
view.hideLoader();
view.showError(task.getError().getMessage());
final Exception error = task.getError();
if (error instanceof TwoStepAuthException) {
view.showTwoStepAuth();
} else {
view.showError(error.getMessage());
}
}
return null;
});
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}
......
......@@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'io.realm:realm-gradle-plugin:2.3.2'
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment