Merge branch 'master' into clients-patch

# Conflicts:
#	util/util.go
This commit is contained in:
kevin 2022-10-02 12:02:09 +08:00
commit 59a4ade8c6
14 changed files with 128 additions and 33 deletions

View file

@ -51,7 +51,18 @@ func Login(db store.IStore) echo.HandlerFunc {
}
userCorrect := subtle.ConstantTimeCompare([]byte(user.Username), []byte(dbuser.Username)) == 1
passwordCorrect := subtle.ConstantTimeCompare([]byte(user.Password), []byte(dbuser.Password)) == 1
var passwordCorrect bool
if dbuser.PasswordHash != "" {
match, err := util.VerifyHash(dbuser.PasswordHash, user.Password)
if err != nil {
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot verify password"})
}
passwordCorrect = match
} else {
passwordCorrect = subtle.ConstantTimeCompare([]byte(user.Password), []byte(dbuser.Password)) == 1
}
if userCorrect && passwordCorrect {
// TODO: refresh the token
sess, _ := session.Get("session", c)