Browse Source

user: MD5加密

Yi 1 year ago
parent
commit
b0305c1395
3 changed files with 4 additions and 8 deletions
  1. 1 3
      http/handle/api/user.go
  2. 1 1
      main.go
  3. 2 4
      service/user_service/user.go

+ 1 - 3
http/handle/api/user.go

@@ -62,15 +62,13 @@ func Auth(c *gin.Context) {
 
 	authService := user_service.User{Username: reqInfo.Username, Password: reqInfo.Password}
 	isExist, err := authService.Check()
-
 	if err != nil {
 		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH_CHECK_TOKEN_FAIL, err)
 		return
 	}
 
 	if !isExist {
-		//appG.Response(http.StatusUnauthorized, e.ERROR_AUTH, nil)
-		appG.Response(http.StatusOK, e.ERROR_AUTH, "用户名或密码错误")
+		appG.Response(http.StatusInternalServerError, e.ERROR_AUTH, "")
 		return
 	}
 

+ 1 - 1
main.go

@@ -84,7 +84,7 @@ func (p *program) run() {
 		logging.Info("[info] start https server listening port %s", httpsPort)
 		_ = httpServer.RunTLS(httpsPort, setting.ServerSetting.CrtPath, setting.ServerSetting.KeyPath)
 	} else if setting.ServerSetting.Https == 2 {
-		logging.Printf("[info] start https & http  server listening port https %s, http %s", httpsPort, server.Addr)
+		logging.Printf("[info] start https & http  server listening port https: %s, http: %s", httpsPort, server.Addr)
 		go httpServer.RunTLS(httpsPort, setting.ServerSetting.CrtPath, setting.ServerSetting.KeyPath)
 		_ = server.ListenAndServe()
 	} else {

+ 2 - 4
service/user_service/user.go

@@ -2,7 +2,6 @@ package user_service
 
 import (
 	"tmr-watch/http/handle/restful"
-	"tmr-watch/pkg/util"
 
 	"github.com/casbin/casbin"
 )
@@ -26,13 +25,12 @@ type User struct {
 }
 
 func (a *User) Check() (bool, error) {
-	return restful.CheckUser(a.Username, util.EncodeMD5(a.Password))
+	return restful.CheckUser(a.Username, a.Password)
 
 }
 
 func (a *User) CheckFace() (bool, error) {
-	return restful.CheckUser(a.Username, util.EncodeMD5(a.Password))
-
+	return restful.CheckUser(a.Username, a.Password)
 }
 
 // func (a *User) CheckImei() (bool, error) {