|
@@ -98,7 +98,7 @@ func (l *loginAuth) AuthCode(ctx context.Context, phone string, code string) (in
|
|
userData = userInfo
|
|
userData = userInfo
|
|
}
|
|
}
|
|
|
|
|
|
- token := l.getToken(ctx, phone)
|
|
|
|
|
|
+ token := l.getToken(ctx, phone, userData.Role)
|
|
var jobData gorm_model.YounggeeJob
|
|
var jobData gorm_model.YounggeeJob
|
|
var accountData gorm_model.YounggeeSubAccount
|
|
var accountData gorm_model.YounggeeSubAccount
|
|
var enterpriseUser gorm_model.Enterprise
|
|
var enterpriseUser gorm_model.Enterprise
|
|
@@ -127,7 +127,8 @@ func (l *loginAuth) AuthCode(ctx context.Context, phone string, code string) (in
|
|
Token: token,
|
|
Token: token,
|
|
EnterpriseID: enterpriseUserInfo.EnterpriseID,
|
|
EnterpriseID: enterpriseUserInfo.EnterpriseID,
|
|
}
|
|
}
|
|
- if sessionErr := l.setSession(ctx, phone, auth); sessionErr != nil {
|
|
|
|
|
|
+ key := phone + userData.Role
|
|
|
|
+ if sessionErr := l.setSession(ctx, key, auth); sessionErr != nil {
|
|
fmt.Printf("setSession error\n")
|
|
fmt.Printf("setSession error\n")
|
|
return 0, nil, sessionErr
|
|
return 0, nil, sessionErr
|
|
}
|
|
}
|
|
@@ -159,7 +160,8 @@ func (l *loginAuth) AuthCode(ctx context.Context, phone string, code string) (in
|
|
}
|
|
}
|
|
if jobInfo != nil {
|
|
if jobInfo != nil {
|
|
jobData = *jobInfo
|
|
jobData = *jobInfo
|
|
- if sessionErr := l.setSession(ctx, phone, auth); sessionErr != nil {
|
|
|
|
|
|
+ key := phone + userData.Role
|
|
|
|
+ if sessionErr := l.setSession(ctx, key, auth); sessionErr != nil {
|
|
fmt.Printf("setSession error\n")
|
|
fmt.Printf("setSession error\n")
|
|
return 0, nil, sessionErr
|
|
return 0, nil, sessionErr
|
|
}
|
|
}
|
|
@@ -264,9 +266,9 @@ func (l *loginAuth) getSessionAuth(ctx context.Context, phone string) (*redis_mo
|
|
return auth, nil
|
|
return auth, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (l *loginAuth) getToken(ctx context.Context, phone string) string {
|
|
|
|
|
|
+func (l *loginAuth) getToken(ctx context.Context, phone string, role string) string {
|
|
timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
|
|
timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
|
|
- token := phone + "." + timeSeed + "." + util.MD5(phone, timeSeed, consts.AuthSalt)
|
|
|
|
|
|
+ token := phone + role + "." + timeSeed + "." + util.MD5(phone+role, timeSeed, consts.AuthSalt)
|
|
return token
|
|
return token
|
|
}
|
|
}
|
|
|
|
|