token-validator: update to handle custom domains
This commit is contained in:
parent
efab34d551
commit
5a4650f70e
4 changed files with 307 additions and 15 deletions
|
|
@ -18,18 +18,27 @@ func (student Student) MyDelegatedDomain() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (student Student) DefaultAssociatedDomain() string {
|
||||
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), AssociatedDomainSuffix)
|
||||
}
|
||||
|
||||
func (student Student) MyAssociatedDomain() string {
|
||||
if student.AssociatedDomain != nil {
|
||||
return *student.AssociatedDomain
|
||||
} else {
|
||||
return fmt.Sprintf("%s.%s", strings.Trim(strings.Replace(student.Login, "_", "-", -1), "-_"), AssociatedDomainSuffix)
|
||||
return student.DefaultAssociatedDomain()
|
||||
}
|
||||
}
|
||||
|
||||
func (student Student) GetAssociatedDomains() (ds []string) {
|
||||
defdn := student.DefaultAssociatedDomain()
|
||||
ds = append(ds, defdn)
|
||||
|
||||
studentDomain := student.MyAssociatedDomain()
|
||||
|
||||
ds = append(ds, studentDomain)
|
||||
if defdn != studentDomain {
|
||||
ds = append(ds, studentDomain)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue