a few fixes for user teleportation

This commit is contained in:
Daniel Goc
2026-04-03 13:55:57 +02:00
parent af91842b14
commit f6b321b602
5 changed files with 17 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ package constdata
const PASSWORD_VALIDATION_REGEX = `^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{10,}$`
const SHOP_ID = 1
const SHOP_DEFAULT_LANGUAGE = 1
const ADMIN_NOTIFICATION_LANGUAGE = 2
// CATEGORY_TREE_ROOT_ID corresponds to id_category in ps_category which has is_root_category=1
const CATEGORY_TREE_ROOT_ID = 2

View File

@@ -8,6 +8,7 @@ import (
"sync"
"git.ma-al.com/goc_daniel/b2b/app/model"
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
"github.com/gofiber/fiber/v3"
)
@@ -177,7 +178,7 @@ func (s *TranslationsStore) ReloadTranslations(translations []model.Translation)
// T_ is meant to be used to translate error messages and other system communicates.
func T_[T ~string](c fiber.Ctx, key T, params ...interface{}) string {
if langID, ok := c.Locals("langID").(uint); ok {
if langID, ok := localeExtractor.GetLangID(c); ok {
parts := strings.Split(string(key), ".")
if len(parts) >= 2 {

View File

@@ -21,3 +21,11 @@ func GetUserID(c fiber.Ctx) (uint, bool) {
}
return user_locale.User.ID, true
}
func GetOriginalUserRole(c fiber.Ctx) (model.CustomerRole, bool) {
user_locale, ok := c.Locals(constdata.USER_LOCALE).(*model.UserLocale)
if !ok || user_locale.OriginalUser == nil {
return "", false
}
return user_locale.OriginalUser.Role, true
}