Ability to create account for members

This commit is contained in:
William Bouzourène 2026-03-18 19:17:25 +01:00
parent 07db65f63f
commit 2e332b8f3e
Signed by: bouzoure
GPG key ID: 423440D735B56BE2
5 changed files with 138 additions and 16 deletions

View file

@ -0,0 +1,57 @@
package authelia
import (
"fmt"
"strings"
"git.readonly.ch/bouzoure/pop-camarades/helpers"
"git.readonly.ch/bouzoure/pop-camarades/models"
)
func GetPersonGroups(userid uint) []string {
var groups []string
db, err := helpers.GetDatabase()
if err != nil {
return groups
}
var person models.Person
db.Preload("Section").Find(&person, "id = ?", userid)
if person.SectionID <= 0 {
return groups
}
groups = append(groups, fmt.Sprintf(
"section_%s",
strings.ReplaceAll(person.Section.ShortName, " ", "_"),
))
if person.Section.ParentSectionID == nil {
return groups
}
parentID := person.Section.ParentSectionID
for {
var section models.Section
db.Preload("parent_section").Find(&section, "id = ?", parentID)
if section.ID <= 0 {
return groups
}
groups = append(groups, fmt.Sprintf(
"section_%s",
strings.ReplaceAll(section.ShortName, " ", "_"),
))
if section.ParentSectionID != nil {
parentID = person.Section.ParentSectionID
} else {
break
}
}
return groups
}