Parcourir la source

Merge branch 'master' of http://git.shengws.com/zhangbj/sso

柳香萍 il y a 5 ans
Parent
révision
7dcfb8af4a

+ 13 - 14
controllers/mobile_regist_controller.go Voir le fichier

@@ -6,7 +6,6 @@ import (
6 6
 	"SSO/service"
7 7
 	"SSO/utils"
8 8
 	"encoding/json"
9
-	"strings"
10 9
 	"time"
11 10
 )
12 11
 
@@ -67,21 +66,21 @@ func (this *MobileRegistController) RegistSubmit() {
67 66
 
68 67
 	redisClient := service.RedisClient()
69 68
 	defer redisClient.Close()
70
-	if strings.HasPrefix(mobile, "12") {
71
-		if code != "123456" {
72
-			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
73
-			this.ServeJSON()
74
-			return
75
-		}
69
+	// if strings.HasPrefix(mobile, "12") {
70
+	// 	if code != "123456" {
71
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
72
+	// 		this.ServeJSON()
73
+	// 		return
74
+	// 	}
76 75
 
77
-	} else {
78
-		cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
79
-		if cache_code != code {
80
-			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
81
-			this.ServeJSON()
82
-			return
83
-		}
76
+	// } else {
77
+	cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
78
+	if cache_code != code {
79
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
80
+		this.ServeJSON()
81
+		return
84 82
 	}
83
+	// }
85 84
 
86 85
 	admin, err := service.RegisterSuperAdmin(mobile, pwd)
87 86
 	if err != nil {

+ 9 - 12
controllers/verification_code_controller.go Voir le fichier

@@ -4,9 +4,6 @@ import (
4 4
 	"SSO/enums"
5 5
 	"SSO/service"
6 6
 	"SSO/utils"
7
-	"strings"
8
-
9
-	"github.com/astaxie/beego"
10 7
 )
11 8
 
12 9
 type CodeController struct {
@@ -54,15 +51,15 @@ func (this *CodeController) RegistCode() {
54 51
 		return
55 52
 	}
56 53
 
57
-	if beego.AppConfig.String("runmode") == "dev" {
58
-		if strings.HasPrefix(mobile, "12") {
59
-			this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
60
-				"msg": "短信发送成功,有效期为10分钟",
61
-			})
62
-			this.ServeJSON()
63
-			return
64
-		}
65
-	}
54
+	// if beego.AppConfig.String("runmode") == "dev" {
55
+	// 	if strings.HasPrefix(mobile, "12") {
56
+	// 		this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
57
+	// 			"msg": "短信发送成功,有效期为10分钟",
58
+	// 		})
59
+	// 		this.ServeJSON()
60
+	// 		return
61
+	// 	}
62
+	// }
66 63
 
67 64
 	if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
68 65
 		this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)

+ 8 - 8
controllers/verify_token_controller.go Voir le fichier

@@ -416,14 +416,6 @@ func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int
416 416
 
417 417
 	// 自动创建所有应用
418 418
 	didCreateNew := false
419
-	if did_patient_manage_create == false {
420
-		err := service.CreateOrgApp(adminUserID, orgID, 1, false)
421
-		if err != nil {
422
-			utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
423
-			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
424
-		}
425
-		didCreateNew = true
426
-	}
427 419
 	if did_dialysis_manage_create == false {
428 420
 		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
429 421
 		if err != nil {
@@ -440,6 +432,14 @@ func (this *VerifyTokenController) _createAppIfNeeded(adminUserID int, orgID int
440 432
 		}
441 433
 		didCreateNew = true
442 434
 	}
435
+	if did_patient_manage_create == false {
436
+		err := service.CreateOrgApp(adminUserID, orgID, 1, false)
437
+		if err != nil {
438
+			utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
439
+			return false, &enums.SGJError{Code: enums.ErrorCodeDataException}
440
+		}
441
+		didCreateNew = true
442
+	}
443 443
 	if did_mall_manage_create == false {
444 444
 		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
445 445
 		if err != nil {

+ 1 - 1
service/login_service.go Voir le fichier

@@ -73,7 +73,7 @@ func GetAdminUserLastLoginLog(adminUserID int, appType int) (*models.AdminUserLo
73 73
 }
74 74
 
75 75
 func GetAdminUserPrioritizedAppType(adminUserID int) (int8, error) {
76
-	rows, err := readUserDb.Raw("SELECT app.app_type FROM sgj_user_org_app AS app, sgj_user_admin_role AS r WHERE r.admin_user_id = ? AND r.app_id = app.id AND app.status = 1 AND r.status = 1 ORDER BY app.org_id ASC, app.app_type ASC LIMIT 1;", adminUserID).Rows()
76
+	rows, err := readUserDb.Raw("SELECT app.app_type FROM sgj_user_org_app AS app, sgj_user_admin_role AS r WHERE r.admin_user_id = ? AND r.app_id = app.id AND app.status = 1 AND app.open_status = 1 AND r.status = 1 ORDER BY app.org_id ASC, app.app_type ASC LIMIT 1;", adminUserID).Rows()
77 77
 	defer rows.Close()
78 78
 	if err != nil {
79 79
 		return 0, err

+ 4 - 3
service/org_service.go Voir le fichier

@@ -30,15 +30,16 @@ func CreateOrg(org *models.Org, mobile string, openXT bool, openCDM bool, openSC
30 30
 		return err
31 31
 	}
32 32
 
33
-	if err := createOrgApp(tx_admin, &role, mobile, 1, openSCRM); err != nil {
33
+	// app 的创建顺序也决定了登录后前往 app 的优先级
34
+	if err := createOrgApp(tx_admin, &role, mobile, 3, openXT); err != nil {
34 35
 		tx_admin.Rollback()
35 36
 		return err
36 37
 	}
37
-	if err := createOrgApp(tx_admin, &role, mobile, 3, openXT); err != nil {
38
+	if err := createOrgApp(tx_admin, &role, mobile, 4, openCDM); err != nil {
38 39
 		tx_admin.Rollback()
39 40
 		return err
40 41
 	}
41
-	if err := createOrgApp(tx_admin, &role, mobile, 4, openCDM); err != nil {
42
+	if err := createOrgApp(tx_admin, &role, mobile, 1, openSCRM); err != nil {
42 43
 		tx_admin.Rollback()
43 44
 		return err
44 45
 	}

+ 8 - 2
views/mobile_site/regist.html Voir le fichier

@@ -77,17 +77,23 @@
77 77
                 aespass: aespass,
78 78
             }
79 79
             $("#codebtn").attr("disabled", true);
80
-            changeNum(60);
81 80
 
82 81
             postRequest("/getregistcode", postData, function(res) {
83 82
                 if (res.state == 0) {
84
-                    serverErrorMsg(res);
83
+                    if (res.code == 604) {
84
+                        $('.layer').show();
85
+                    } else {
86
+                        serverErrorMsg(res);
87
+                    }
85 88
                     return;
86 89
                 }
90
+                changeNum(60);
87 91
                 layer.msg(res.data.msg);
92
+                $("#codebtn").attr("disabled", false);
88 93
 
89 94
             }, function(res) {
90 95
                 serverErrorMsg(res);
96
+                $("#codebtn").attr("disabled", false);
91 97
             });
92 98
         });
93 99