Kaynağa Gözat

auto login need face detect login

billyyoyo 6 yıl önce
ebeveyn
işleme
0f2ac8ace9

+ 4 - 1
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1920,6 +1920,9 @@ public interface ApiService {
     @GET("app/user/check_authorization")
     Observable<BaseMessage> checkAuth(@Query("Authorization") String token);
 
+    @GET("app/user/check_authorization")
+    Observable<BaseMessage> checkAuth(@Query("Authorization") String token, @Query("face_url") String face_url);
+
     @GET("app/search")
     Observable<BaseMessage> search(@Query("keyword") String keyword, @Query("game_count") int gameCount, @Query("task_count") int taskCount, @Query("gift_count") int giftCount, @Query("article_count") int articleCount);
 
@@ -1933,7 +1936,7 @@ public interface ApiService {
     Observable<BaseMessage> needPayPwd();
 
     @POST("app/user/check_pay_pwd")
-    Observable<BaseMessage> checkPayPwd(@Header("Authorization")String token, @Body JSONObject jsonObject);
+    Observable<BaseMessage> checkPayPwd(@Header("Authorization") String token, @Body JSONObject jsonObject);
 
     @POST("app/user/set_pay_pwd")
     Observable<BaseMessage> setPayPwd(@Body JSONObject jsonObject);

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/util/CertificationUtil.java

@@ -119,9 +119,9 @@ public class CertificationUtil {
                     public void onError(BaseMessage baseMessage) {
                         ViewUtil.newInstance().hideProgress(activity);
                         if (baseMessage.getCode() == 404000022) {
-                            Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_LIVENESS, token);
+                            Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_LIVENESS, token, "auth");
                         } else if (baseMessage.getCode() == 404000023) {
-                            Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_FACE, token);
+                            Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_FACE, token, "auth");
                         } else if(baseMessage.getCode() == 404000024){
                             G.showToast("提示:请在小绵羊APP内完成当前账号绑定手机号");
                         } else if(baseMessage.getCode() == 404000025){

+ 32 - 0
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -1429,6 +1429,38 @@ public class CommonUtil {
                 });
     }
 
+    public void checkAuth(Activity activity, String token, String face, final Action1<Boolean> action1) {
+        SheepApp.getInstance()
+                .getNetComponent()
+                .getApiService()
+                .checkAuth(token, face)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        if (baseMessage.getCode() == 404000022) {
+                            Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_LIVENESS, token, "check");
+                        } else if (baseMessage.getCode() == 404000023) {
+                            Jump2View.getInstance().goFaceWithQR(activity, Constant.INTENT_DETECT_FACE, token, "check");
+                        } else if(baseMessage.getCode() == 404000024){
+                            G.showToast("提示:请在小绵羊APP内完成当前账号绑定手机号");
+                        } else if(baseMessage.getCode() == 404000025){
+                            G.showToast("提示:请在小绵羊APP内完成当前账号实名认证");
+                        }
+                        if (action1 != null)
+                            action1.call(false);
+
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        if (action1 != null)
+                            action1.call(baseMessage.getData(Boolean.class));
+                    }
+                });
+    }
+
     public void callActionWithUserInfo(final Action1<UserEntity> action1) {
         UserEntity userEntity = DataUtil.getInstance().getUserEntity();
         if (userEntity == null || DataUtil.getInstance().isChange()) {

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -860,10 +860,11 @@ public class Jump2View {
      * @param type
      * @param token
      */
-    public void goFaceWithQR(Activity activity, int type, String token) {
+    public void goFaceWithQR(Activity activity, int type, String token, String extra) {
         Intent in = new Intent(activity, FaceWithQRActivity.class);
         in.putExtra("type", type);
         in.putExtra("token", token);
+        in.putExtra("extra", extra);
         activity.startActivityForResult(in, Constant.INTENT_DETECT_FACE);
     }
 

+ 15 - 9
app/src/main/java/com/sheep/gamegroup/view/activity/GameCertificationActivity.java

@@ -129,15 +129,12 @@ public class GameCertificationActivity extends BaseActivity {
             SdkLoginUser gameUser = DDProviderHelper.getInstance().getSdkLoginUser(gameToken);
             if (gameUser != null) {
                 gameToken = gameUser.getToken();
-                CommonUtil.getInstance().checkAuth(gameToken, new Action1<Boolean>() {
-                    @Override
-                    public void call(Boolean ret) {
-                        if (ret) {
-                            CertificationUtil.newInstance().doCertification(GameCertificationActivity.this, gameToken, packageName, "validate");
-                        } else {
-                            hasToken();
+                CommonUtil.getInstance().checkAuth(gameToken, (ret) -> {
+                    if (ret) {
+                        CertificationUtil.newInstance().doCertification(GameCertificationActivity.this, gameToken, packageName, "validate");
+                    } else {
+                        hasToken();
 
-                        }
                     }
                 });
                 return;
@@ -186,7 +183,16 @@ public class GameCertificationActivity extends BaseActivity {
         if (requestCode == Constant.INTENT_DETECT_FACE && resultCode == RESULT_OK && data != null) {
             String token = data.getStringExtra("token");
             String face = data.getStringExtra("face");
-            CertificationUtil.newInstance().authCertificationCode(GameCertificationActivity.this, token, face);
+            String extra = data.getStringExtra("extra");
+            if("check".equals(extra)){
+                CommonUtil.getInstance().checkAuth(gameToken, (ret) -> {
+                    if (ret) {
+                        CertificationUtil.newInstance().doCertification(GameCertificationActivity.this, gameToken, packageName, "validate");
+                    }
+                });
+            } else {
+                CertificationUtil.newInstance().authCertificationCode(GameCertificationActivity.this, token, face);
+            }
         }
     }