This repository has been archived on 2024-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
adlin/libadlin/domain.go

45 lines
1.0 KiB
Go
Raw Normal View History

2020-03-27 13:57:14 +00:00
package adlin
import (
"fmt"
"strings"
)
const (
2021-03-03 17:42:41 +00:00
AssociatedDomainSuffix = "adlin2022.p0m.fr."
2020-03-27 13:57:14 +00:00
DelegatedDomainSuffix = "srs.p0m.fr."
)
2021-03-07 11:39:38 +00:00
func (student *Student) MyDelegatedDomain() string {
if student.DelegatedDomain != nil {
return *student.DelegatedDomain
} else {
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), DelegatedDomainSuffix)
}
2020-03-27 13:57:14 +00:00
}
2021-03-07 11:39:38 +00:00
func (student *Student) DefaultAssociatedDomain() string {
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), AssociatedDomainSuffix)
}
2021-03-07 11:39:38 +00:00
func (student *Student) MyAssociatedDomain() string {
if student.AssociatedDomain != nil {
return *student.AssociatedDomain
} else {
return student.DefaultAssociatedDomain()
}
2020-03-27 13:57:14 +00:00
}
2021-03-07 11:39:38 +00:00
func (student *Student) GetAssociatedDomains() (ds []string) {
defdn := student.DefaultAssociatedDomain()
ds = append(ds, defdn)
2020-03-27 13:57:14 +00:00
studentDomain := student.MyAssociatedDomain()
if defdn != studentDomain {
ds = append(ds, studentDomain)
}
2020-03-27 13:57:14 +00:00
return
}