|
8 | 8 | "github.com/cloudwego/hertz/pkg/app" |
9 | 9 | "github.com/cloudwego/hertz/pkg/protocol/consts" |
10 | 10 | "github.com/golang-module/carbon/v2" |
11 | | - password_hashed "github.com/masx200/go_ws_sh/password-hashed" |
12 | 11 | "gorm.io/gorm" |
| 12 | + |
| 13 | + password_hashed "github.com/masx200/go_ws_sh/password-hashed" |
13 | 14 | ) |
14 | 15 |
|
15 | 16 | func FormatTimeWithCarbon(t carbon.Carbon) string { |
@@ -41,10 +42,10 @@ func UpdateTokenHandler(credentialdb *gorm.DB, tokendb *gorm.DB, sessiondb *gorm |
41 | 42 | } |
42 | 43 |
|
43 | 44 | // 验证身份 |
44 | | - validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
45 | | - if validateFailure { |
46 | | - return |
47 | | - } |
| 45 | + // validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
| 46 | + // if validateFailure { |
| 47 | + // return |
| 48 | + // } |
48 | 49 |
|
49 | 50 | // 检查 Identifier 是否为空 |
50 | 51 | if body.Token.Identifier == "" { |
@@ -130,11 +131,11 @@ func GetCredentialsHandler(credentialdb *gorm.DB, tokendb *gorm.DB, sessiondb *g |
130 | 131 | } |
131 | 132 |
|
132 | 133 | // 验证身份 |
133 | | - validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
134 | | - if validateFailure { |
135 | | - log.Println("用户登录失败:") |
136 | | - return |
137 | | - } |
| 134 | + // validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
| 135 | + // if validateFailure { |
| 136 | + // log.Println("用户登录失败:") |
| 137 | + // return |
| 138 | + // } |
138 | 139 |
|
139 | 140 | // 查询所有用户的认证信息 |
140 | 141 | var credentials []CredentialStore |
@@ -223,13 +224,13 @@ func CreateCredentialHandler(credentialdb *gorm.DB, tokendb *gorm.DB, sessiondb |
223 | 224 | // r.AbortWithMsg("Error: Invalid credentials", consts.StatusUnauthorized) |
224 | 225 | // return |
225 | 226 | // } |
226 | | - var reqcre CredentialsClient = req.Authorization |
| 227 | + // var reqcre CredentialsClient = req.Authorization |
227 | 228 | // 验证旧密码 |
228 | 229 | // 假设已经有一个函数 ValidatePassword 用于验证密码 |
229 | | - validateFailure := Validatepasswordortoken(reqcre, credentialdb, tokendb, r) |
230 | | - if validateFailure { |
231 | | - return |
232 | | - } |
| 230 | + // validateFailure := Validatepasswordortoken(reqcre, credentialdb, tokendb, r) |
| 231 | + // if validateFailure { |
| 232 | + // return |
| 233 | + // } |
233 | 234 | // 更新密码 |
234 | 235 | newHashresult, err := password_hashed.HashPasswordWithSalt(req.Credential.Password, password_hashed.Options{Algorithm: "SHA-512"}) |
235 | 236 |
|
@@ -293,10 +294,10 @@ func CreateSessionHandler(credentialdb *gorm.DB, tokendb *gorm.DB, sessiondb *go |
293 | 294 | } |
294 | 295 |
|
295 | 296 | // 验证身份 |
296 | | - validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
297 | | - if validateFailure { |
298 | | - return |
299 | | - } |
| 297 | + // validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
| 298 | + // if validateFailure { |
| 299 | + // return |
| 300 | + // } |
300 | 301 |
|
301 | 302 | // 检查 Name 是否为空 |
302 | 303 | if body.Session.Name == "" || body.Session.Cmd == "" || body.Session.Dir == "" { |
@@ -398,10 +399,10 @@ func UpdateSessionHandler(credentialdb *gorm.DB, tokendb *gorm.DB, sessiondb *go |
398 | 399 | } |
399 | 400 |
|
400 | 401 | // 验证身份 |
401 | | - validateFailure := Validatepasswordortoken(req.Authorization, credentialdb, tokendb, r) |
402 | | - if validateFailure { |
403 | | - return |
404 | | - } |
| 402 | + // validateFailure := Validatepasswordortoken(req.Authorization, credentialdb, tokendb, r) |
| 403 | + // if validateFailure { |
| 404 | + // return |
| 405 | + // } |
405 | 406 |
|
406 | 407 | // 检查 Name 是否为空 |
407 | 408 | if req.Session.Name == "" { |
@@ -486,12 +487,12 @@ func GetSessionsHandler(credentialdb *gorm.DB, tokendb *gorm.DB, sessiondb *gorm |
486 | 487 | } |
487 | 488 | log.Println(body) |
488 | 489 |
|
489 | | - validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
490 | | - if validateFailure { |
491 | | - log.Println("用户登录失败:") |
492 | | - return |
493 | | - } |
494 | | - log.Println("用户登录成功:") |
| 490 | + // validateFailure := Validatepasswordortoken(body.Authorization, credentialdb, tokendb, r) |
| 491 | + // if validateFailure { |
| 492 | + // log.Println("用户登录失败:") |
| 493 | + // return |
| 494 | + // } |
| 495 | + // log.Println("用户登录成功:") |
495 | 496 |
|
496 | 497 | username := body.Authorization.Username |
497 | 498 | if username == "" { |
|
0 commit comments