admin: Fix dex template
This commit is contained in:
parent
4973f7ac4a
commit
fbc84f9d08
1 changed files with 7 additions and 2 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"text/template"
|
||||
"unicode"
|
||||
|
||||
|
@ -242,7 +241,7 @@ func genDexConfig() ([]byte, error) {
|
|||
|
||||
logoPath := ""
|
||||
if len(challengeInfo.MainLogo) > 0 {
|
||||
logoPath = strings.Replace(challengeInfo.MainLogo[len(challengeInfo.MainLogo)-1], "$FILES$", fic.FilesDir, -1)
|
||||
logoPath = path.Join("../../files", "logo", path.Base(challengeInfo.MainLogo[len(challengeInfo.MainLogo)-1]))
|
||||
}
|
||||
|
||||
dexTmpl, err := template.New("dexcfg").Parse(dexcfgtpl)
|
||||
|
@ -286,6 +285,11 @@ func genDexConfig() ([]byte, error) {
|
|||
}
|
||||
|
||||
func genDexPasswordTpl() ([]byte, error) {
|
||||
challengeInfo, err := GetChallengeInfo()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Cannot create template: %w", err)
|
||||
}
|
||||
|
||||
if teams, err := fic.GetTeams(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
|
@ -295,6 +299,7 @@ func genDexPasswordTpl() ([]byte, error) {
|
|||
return nil, fmt.Errorf("Cannot create template: %w", err)
|
||||
} else if err = dexTmpl.Execute(b, dexConfig{
|
||||
Teams: teams,
|
||||
Name: challengeInfo.Title,
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("An error occurs during template execution: %w", err)
|
||||
} else {
|
||||
|
|
Reference in a new issue