Implement KeepUpdated. Switch to Logrus logger. Relocate score-related functions.

This commit is contained in:
MaxJa4
2024-01-22 16:03:18 +01:00
parent 7cdc18bd78
commit da1ff4e4e5
16 changed files with 348 additions and 280 deletions

View File

@@ -3,13 +3,13 @@ package main
import (
"InfantrySkillCalculator/controllers"
"InfantrySkillCalculator/models"
"InfantrySkillCalculator/utils"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"golang.org/x/crypto/bcrypt"
"gorm.io/gorm"
"internal/session"
"log"
"net/http"
)
@@ -30,7 +30,7 @@ func getUserPassword(username string) (string, error) {
if err := models.DB.Where("username = ?", username).First(&user).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
log.Fatal(err)
utils.Logger.Fatal(err)
}
return "", err
}
@@ -90,7 +90,7 @@ func AdminAuthRequired() gin.HandlerFunc {
func redirectToLogin(c *gin.Context) {
if err := session.InvalidateSession(c); err != nil {
log.Fatal(err)
utils.Logger.Fatal(err)
}
c.Redirect(http.StatusFound, "/login")
c.Abort()