admin: Also generate associations when generating dex.yaml

This commit is contained in:
nemunaire 2022-06-04 18:10:09 +02:00
parent 2ce95ccafc
commit d09c1741a2
2 changed files with 10 additions and 22 deletions

View file

@ -6,6 +6,7 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"path"
"text/template"
@ -205,6 +206,14 @@ func genDexConfig() ([]byte, error) {
}); err != nil {
return nil, fmt.Errorf("An error occurs during template execution: %w", err)
} else {
// Also generate team associations
for _, team := range teams {
if err := os.Symlink(fmt.Sprintf("%d", team.Id), path.Join(TeamsDir, fmt.Sprintf("%02d", team.Id))); err != nil {
log.Println("Unable to create association symlink:", err.Error())
return nil, fmt.Errorf("Unable to create association symlink: %s", err.Error())
}
}
return b.Bytes(), nil
}
}