add new db handler with table change to reference many2many

This commit is contained in:
Adrian Zürcher
2025-11-19 16:29:37 +01:00
parent 567cc726cc
commit 2736aa1f6b
9 changed files with 103 additions and 130 deletions

View File

@@ -78,7 +78,7 @@ func (aH *AccessHandler) Login(c *gin.Context) {
accessToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"id": user.Id,
"username": user.Name,
"role": user.Role,
"role": user.Role.Role,
"type": "access",
"exp": accessTokenExp.Unix(),
})
@@ -87,7 +87,7 @@ func (aH *AccessHandler) Login(c *gin.Context) {
refreshToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"id": user.Id,
"username": user.Name,
"role": user.Role,
"role": user.Role.Role,
"type": "refresh",
"exp": refreshTokenExp.Unix(),
})
@@ -125,7 +125,7 @@ func (aH *AccessHandler) Login(c *gin.Context) {
"message": "login successful",
"id": user.Id,
"user": user.Name,
"role": user.Role,
"role": user.Role.Role,
"settings": user.Settings,
})
}
@@ -177,7 +177,7 @@ func (aH *AccessHandler) Refresh(c *gin.Context) {
newAccess := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"id": id,
"username": username,
"role": user.Role,
"role": user.Role.Role,
"exp": accessExp.Unix(),
})
accessString, _ := newAccess.SignedString(ACCESS_SECRET)
@@ -241,7 +241,7 @@ func (aH *AccessHandler) getUserFromDB(c *gin.Context, userName string) (user mo
hasError = true
// Fetch user record from DB
var dbRecord []models.User
err := aH.dbHandler.GetByKey(&dbRecord, "user_name", userName, false)
err := aH.dbHandler.GetByKey(&dbRecord, "Role", "user_name", userName, false)
if err != nil {
aH.logger.Error("Login", err)
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))