登录错误提示优化
This commit is contained in:
@@ -20,13 +20,11 @@ import androidx.core.content.ContextCompat;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.UIHelper;
|
||||
import com.yizhuan.erban.base.BaseLoginAct;
|
||||
import com.yizhuan.erban.ui.login.ui.CodeEditText;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.BanAccountException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.IsSuperAdminException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.ShowPhoneCodeException;
|
||||
import com.yizhuan.xchat_android_core.code.CodeType;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
@@ -45,7 +43,6 @@ import java.util.Locale;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Action;
|
||||
|
||||
/**
|
||||
* @author zhouxiangfeng
|
||||
@@ -204,10 +201,6 @@ public class BindCodeActivity extends BaseLoginAct {
|
||||
start, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
getDialogManager().showOkCancelWithTitleDialog("您被封号了",
|
||||
spannableString, "确定", "取消", null);
|
||||
} else if (e instanceof ShowPhoneCodeException) {
|
||||
isSuperAdmin = false;
|
||||
ShowPhoneCodeException showPhoneCodeException = (ShowPhoneCodeException) e;
|
||||
toast(e.getMessage());
|
||||
} else if (e instanceof IOException) {
|
||||
toast("网络异常,请检查您的网络再试~");
|
||||
} else {
|
||||
|
@@ -22,14 +22,12 @@ import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.base.BaseLoginAct;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.ui.login.ui.CodeEditText;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.auth.event.LoginEvent;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.AccountCancelException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.BanAccountException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.IsSuperAdminException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.ShowPhoneCodeException;
|
||||
import com.yizhuan.xchat_android_core.code.CodeType;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
@@ -254,10 +252,6 @@ public class LoginCodeActivity extends BaseLoginAct {
|
||||
0, end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
getDialogManager().showOkWithTitleDialog("该账号已注销",
|
||||
spannableString, "我知道了", true, null);
|
||||
} else if (e instanceof ShowPhoneCodeException) {
|
||||
isSuperAdmin = false;
|
||||
ShowPhoneCodeException showPhoneCodeException = (ShowPhoneCodeException) e;
|
||||
toast(e.getMessage());
|
||||
} else if (e instanceof IOException) {
|
||||
toast("网络异常,请检查您的网络再试~");
|
||||
} else {
|
||||
|
@@ -31,7 +31,6 @@ import com.yizhuan.xchat_android_core.auth.exception.AccountCancelException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.BanAccountException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.BigHeadPhoneException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.IsSuperAdminException;
|
||||
import com.yizhuan.xchat_android_core.auth.exception.ShowPhoneCodeException;
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.bean.response.result.LoginResult;
|
||||
@@ -86,23 +85,36 @@ import retrofit2.http.Query;
|
||||
|
||||
public class AuthModel extends BaseModel implements IAuthModel {
|
||||
|
||||
/**
|
||||
* 封禁账号
|
||||
*/
|
||||
public static final int CODE_BAN_ACCOUNT = 407;
|
||||
/**
|
||||
* 封禁设备
|
||||
*/
|
||||
public static final int CODE_BAN_DEVICE = 408;
|
||||
/**
|
||||
* 验证码结果不正确
|
||||
*/
|
||||
public static final int VERIFY_CODE_ERROR = 3002; // 图片验证码?
|
||||
/**
|
||||
* 账号已注销
|
||||
*/
|
||||
public static final int CODE_ACCOUNT_CANCEL = 3009;
|
||||
/**
|
||||
* 注册异常,请稍后再试
|
||||
*/
|
||||
public static final int CODE_HIT_YI_DUN = 24000;
|
||||
/**
|
||||
* 一个手机绑定多个账号(大头账号)
|
||||
*/
|
||||
public static final int CODE_BIG_HEAD_NUM = 25002;
|
||||
private static final String TAG = "AuthModel";
|
||||
|
||||
/**
|
||||
* 类型(1、手机号/耳伴号登陆,2、手机号/耳伴号登陆并绑定QQ)
|
||||
*/
|
||||
private static final int TYPE_LOGIN_NORMAL = 1;
|
||||
private static final int TYPE_LOGIN_BIND_QQ = 2;
|
||||
|
||||
/**
|
||||
* 封禁账号
|
||||
*/
|
||||
public static final int CODE_BAN_ACCOUNT = 407;
|
||||
|
||||
/**
|
||||
* 封禁设备
|
||||
*/
|
||||
public static final int CODE_BAN_DEVICE = 408;
|
||||
/**
|
||||
* 校验验证码
|
||||
*/
|
||||
@@ -111,44 +123,24 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
* 超管登录校验验证码
|
||||
*/
|
||||
private static final int SUPER_CODE_SHOW_CODE = 136;
|
||||
|
||||
/**
|
||||
* 验证码结果不正确
|
||||
*/
|
||||
public static final int VERIFY_CODE_ERROR = 3002; // 图片验证码?
|
||||
|
||||
/**
|
||||
* 账号已注销
|
||||
*/
|
||||
public static final int CODE_ACCOUNT_CANCEL = 3009;
|
||||
|
||||
/**
|
||||
* 注册异常,请稍后再试
|
||||
*/
|
||||
public static final int CODE_HIT_YI_DUN = 24000;
|
||||
|
||||
/**
|
||||
* 一个手机绑定多个账号(大头账号)
|
||||
*/
|
||||
public static final int CODE_BIG_HEAD_NUM = 25002;
|
||||
|
||||
|
||||
private Api api;
|
||||
|
||||
@Getter
|
||||
private AccountInfo currentAccountInfo;
|
||||
private TicketInfo ticketInfo;
|
||||
|
||||
private ThirdUserInfo thirdUserInfo;
|
||||
private static final int TYPE_WECHAT_LOGIN = 1;//微信登录类型
|
||||
private static final int TYPE_QQ_LOGIN = 2;//QQ登录类型
|
||||
private Platform wechat;
|
||||
private Platform qq;
|
||||
private volatile static AuthModel instance = null;
|
||||
/**
|
||||
* 是否来源于登录
|
||||
*/
|
||||
public boolean isFromLogin = false;
|
||||
private volatile static AuthModel instance = null;
|
||||
boolean isInit = false;
|
||||
private Api api;
|
||||
@Getter
|
||||
private AccountInfo currentAccountInfo;
|
||||
private TicketInfo ticketInfo;
|
||||
private ThirdUserInfo thirdUserInfo;
|
||||
private Platform wechat;
|
||||
private Platform qq;
|
||||
/****************************************************** IM *************************************************************/
|
||||
|
||||
private StatusCode statusCode;
|
||||
|
||||
private AuthModel() {
|
||||
api = RxNet.create(Api.class);
|
||||
@@ -282,8 +274,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
emitter.onError(new BanAccountException(loginResult.getReason(), loginResult.getDate()));
|
||||
} else if (loginResult.getCode() == CODE_ACCOUNT_CANCEL) {
|
||||
emitter.onError(new AccountCancelException(loginResult.getMessage(), loginResult.getErbanNo(), loginResult.getCancelDate()));
|
||||
} else if (loginResult.getCode() == CODE_SHOW_CODE) {
|
||||
emitter.onError(new ShowPhoneCodeException(loginResult.getMessage(), loginResult.isVerifyCode()));
|
||||
} else if (loginResult.getCode() == SUPER_CODE_SHOW_CODE) {
|
||||
//是否是超管
|
||||
if (loginResult.getSuperCodeVerify() == 1) {
|
||||
@@ -301,8 +291,7 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
//成功获取到uid后,就通知首页刷新审核中状态的数据
|
||||
EventBus.getDefault().post(new GetCurrentUidEvent(true));
|
||||
} catch (Exception e) {
|
||||
emitter.onError(handleException(e));
|
||||
//emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
||||
emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
||||
return;
|
||||
}
|
||||
//获取tick
|
||||
@@ -339,36 +328,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理异常
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
private Exception handleException(Exception e) {
|
||||
try {
|
||||
if (e instanceof HttpException) {
|
||||
Response response = ((HttpException) e).response();
|
||||
if (response != null) {
|
||||
ResponseBody errorBody = response.errorBody();
|
||||
if (errorBody != null) {
|
||||
String content = errorBody.string();
|
||||
LoginResult result = new Gson().fromJson(content, LoginResult.class);
|
||||
if (result != null) {
|
||||
if (result.isVerifyCode()) {
|
||||
return new ShowPhoneCodeException(result.getMessage(), result.isVerifyCode());
|
||||
} else {
|
||||
return new RuntimeException(result.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信登录
|
||||
@@ -600,8 +559,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
emitter.onError(new BanAccountException(loginResult.getReason(), loginResult.getDate()));
|
||||
} else if (loginResult.getCode() == CODE_ACCOUNT_CANCEL) {
|
||||
emitter.onError(new AccountCancelException(loginResult.getMessage(), loginResult.getErbanNo(), loginResult.getCancelDate()));
|
||||
} else if (loginResult.getCode() == CODE_SHOW_CODE) {
|
||||
emitter.onError(new ShowPhoneCodeException(loginResult.getMessage(), loginResult.isVerifyCode()));
|
||||
} else if (loginResult.getCode() == SUPER_CODE_SHOW_CODE) {
|
||||
//是否是超管
|
||||
if (loginResult.getSuperCodeVerify() == 1) {
|
||||
@@ -621,8 +578,7 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
//成功获取到uid后,就通知首页刷新审核中状态的数据
|
||||
EventBus.getDefault().post(new GetCurrentUidEvent(true));
|
||||
} catch (Exception e) {
|
||||
emitter.onError(handleException(e));
|
||||
//emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
||||
emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
||||
return;
|
||||
}
|
||||
//获取tick
|
||||
@@ -697,7 +653,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
*
|
||||
@@ -944,7 +899,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
EventBus.getDefault().post(new LogoutEvent());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改登录密码
|
||||
*
|
||||
@@ -1024,10 +978,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
}
|
||||
|
||||
/****************************************************** IM *************************************************************/
|
||||
|
||||
private StatusCode statusCode;
|
||||
|
||||
/**
|
||||
* 判断IM 登录状态
|
||||
*
|
||||
@@ -1038,9 +988,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
||||
return statusCode == StatusCode.LOGINED;
|
||||
}
|
||||
|
||||
|
||||
boolean isInit = false;
|
||||
|
||||
/**
|
||||
* 观察Im连接状态
|
||||
*/
|
||||
|
@@ -1,14 +0,0 @@
|
||||
package com.yizhuan.xchat_android_core.auth.exception;
|
||||
|
||||
public class ShowPhoneCodeException extends Exception {
|
||||
private final boolean showPhoneCode;
|
||||
|
||||
public ShowPhoneCodeException(String message, boolean showPhoneCode) {
|
||||
super(message);
|
||||
this.showPhoneCode = showPhoneCode;
|
||||
}
|
||||
|
||||
public boolean isShowPhoneCode() {
|
||||
return showPhoneCode;
|
||||
}
|
||||
}
|
@@ -20,7 +20,12 @@ public class OldHttpErrorHandleUtil {
|
||||
if (bodyByte.length <= 0) {
|
||||
return throwable.getMessage();
|
||||
}
|
||||
ServiceResult result = new Gson().fromJson(new String(bodyByte, Charset.forName("UTF-8")), ServiceResult.class);
|
||||
ServiceResult result;
|
||||
try {
|
||||
result = new Gson().fromJson(new String(bodyByte, Charset.forName("UTF-8")), ServiceResult.class);
|
||||
} catch (Exception e) {
|
||||
return "大鹅开小差中~请稍后再试";
|
||||
}
|
||||
return result.getMessage();
|
||||
} else {
|
||||
return throwable.getMessage();
|
||||
|
Reference in New Issue
Block a user