Browse Source

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

柳香萍 5 years ago
parent
commit
7dcfb8af4a

+ 13 - 14
controllers/mobile_regist_controller.go View File

6
 	"SSO/service"
6
 	"SSO/service"
7
 	"SSO/utils"
7
 	"SSO/utils"
8
 	"encoding/json"
8
 	"encoding/json"
9
-	"strings"
10
 	"time"
9
 	"time"
11
 )
10
 )
12
 
11
 
67
 
66
 
68
 	redisClient := service.RedisClient()
67
 	redisClient := service.RedisClient()
69
 	defer redisClient.Close()
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
 	admin, err := service.RegisterSuperAdmin(mobile, pwd)
85
 	admin, err := service.RegisterSuperAdmin(mobile, pwd)
87
 	if err != nil {
86
 	if err != nil {

+ 9 - 12
controllers/verification_code_controller.go View File

4
 	"SSO/enums"
4
 	"SSO/enums"
5
 	"SSO/service"
5
 	"SSO/service"
6
 	"SSO/utils"
6
 	"SSO/utils"
7
-	"strings"
8
-
9
-	"github.com/astaxie/beego"
10
 )
7
 )
11
 
8
 
12
 type CodeController struct {
9
 type CodeController struct {
54
 		return
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
 	if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
64
 	if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
68
 		this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
65
 		this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)

+ 8 - 8
controllers/verify_token_controller.go View File

416
 
416
 
417
 	// 自动创建所有应用
417
 	// 自动创建所有应用
418
 	didCreateNew := false
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
 	if did_dialysis_manage_create == false {
419
 	if did_dialysis_manage_create == false {
428
 		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
420
 		err := service.CreateOrgApp(adminUserID, orgID, 3, false)
429
 		if err != nil {
421
 		if err != nil {
440
 		}
432
 		}
441
 		didCreateNew = true
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
 	if did_mall_manage_create == false {
443
 	if did_mall_manage_create == false {
444
 		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
444
 		err := service.CreateOrgApp(adminUserID, orgID, 5, false)
445
 		if err != nil {
445
 		if err != nil {

+ 1 - 1
service/login_service.go View File

73
 }
73
 }
74
 
74
 
75
 func GetAdminUserPrioritizedAppType(adminUserID int) (int8, error) {
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
 	defer rows.Close()
77
 	defer rows.Close()
78
 	if err != nil {
78
 	if err != nil {
79
 		return 0, err
79
 		return 0, err

+ 4 - 3
service/org_service.go View File

30
 		return err
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
 		tx_admin.Rollback()
35
 		tx_admin.Rollback()
35
 		return err
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
 		tx_admin.Rollback()
39
 		tx_admin.Rollback()
39
 		return err
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
 		tx_admin.Rollback()
43
 		tx_admin.Rollback()
43
 		return err
44
 		return err
44
 	}
45
 	}

+ 8 - 2
views/mobile_site/regist.html View File

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