mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-24 06:28:42 +01:00
fix: resets session for existing users who do not have roles defined (#4141)
This commit is contained in:
@@ -17,12 +17,8 @@ const (
|
|||||||
|
|
||||||
const All = Shell | Actions | Download
|
const All = Shell | Actions | Download
|
||||||
|
|
||||||
// ParseRole parses a comma-separated string of roles and returns the corresponding Role. Default is All for empty input.
|
// ParseRole parses a comma-separated string of roles and returns the corresponding Role.
|
||||||
func ParseRole(commaValues string) Role {
|
func ParseRole(commaValues string) Role {
|
||||||
if strings.TrimSpace(commaValues) == "" {
|
|
||||||
return All
|
|
||||||
}
|
|
||||||
|
|
||||||
var roles Role
|
var roles Role
|
||||||
for r := range strings.SplitSeq(commaValues, ",") {
|
for r := range strings.SplitSeq(commaValues, ",") {
|
||||||
role := strings.TrimSpace(strings.ToLower(r))
|
role := strings.TrimSpace(strings.ToLower(r))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/amir20/dozzle/internal/container"
|
"github.com/amir20/dozzle/internal/container"
|
||||||
@@ -113,6 +114,10 @@ func decodeUsersFromFile(path string) (UserDatabase, error) {
|
|||||||
user.Name = username
|
user.Name = username
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.TrimSpace(user.RolesConfigured) == "" {
|
||||||
|
user.RolesConfigured = "all"
|
||||||
|
}
|
||||||
|
|
||||||
user.Roles = ParseRole(user.RolesConfigured)
|
user.Roles = ParseRole(user.RolesConfigured)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user