chore: code adjustment (#512)

This commit is contained in:
Khanh Ngo 2023-12-29 10:56:37 +01:00 committed by GitHub
parent 8cfe9a3d5b
commit 45849a2aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 69 deletions

View file

@ -75,7 +75,8 @@ func Login(db store.IStore) echo.HandlerFunc {
dbuser, err := db.GetUserByName(username)
if err != nil {
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot query user from DB"})
log.Infof("Cannot query user %s from DB", username)
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Invalid credentials"})
}
userCorrect := subtle.ConstantTimeCompare([]byte(username), []byte(dbuser.Username)) == 1
@ -173,7 +174,7 @@ func Logout() echo.HandlerFunc {
}
// LoadProfile to load user information
func LoadProfile(db store.IStore) echo.HandlerFunc {
func LoadProfile() echo.HandlerFunc {
return func(c echo.Context) error {
return c.Render(http.StatusOK, "profile.html", map[string]interface{}{
"baseData": model.BaseData{Active: "profile", CurrentUser: currentUser(c), Admin: isAdmin(c)},
@ -182,7 +183,7 @@ func LoadProfile(db store.IStore) echo.HandlerFunc {
}
// UsersSettings handler
func UsersSettings(db store.IStore) echo.HandlerFunc {
func UsersSettings() echo.HandlerFunc {
return func(c echo.Context) error {
return c.Render(http.StatusOK, "users_settings.html", map[string]interface{}{
"baseData": model.BaseData{Active: "users-settings", CurrentUser: currentUser(c), Admin: isAdmin(c)},