fix: only show external login text when providers available (#768)

This commit is contained in:
Livio Amstutz 2020-09-21 14:06:54 +02:00 committed by GitHub
parent da8f243129
commit 9887e897ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -31,7 +31,10 @@ func NewRenderer(dir http.FileSystem, tmplMapping map[string]string, funcs map[s
if err != nil {
return nil, err
}
r.loadTemplates(dir, tmplMapping, funcs)
err = r.loadTemplates(dir, tmplMapping, funcs)
if err != nil {
return nil, err
}
return r, nil
}

View File

@ -68,5 +68,10 @@ func (l *Login) renderLogin(w http.ResponseWriter, r *http.Request, authReq *mod
errMessage = l.getErrorMessage(r, err)
}
data := l.getUserData(r, authReq, "Login", errType, errMessage)
l.renderer.RenderTemplate(w, r, l.renderer.Templates[tmplLogin], data, nil)
funcs := map[string]interface{}{
"hasExternalLogin": func() bool {
return authReq.LoginPolicy.AllowExternalIDP && authReq.AllowedExternalIDPs != nil && len(authReq.AllowedExternalIDPs) > 0
},
}
l.renderer.RenderTemplate(w, r, l.renderer.Templates[tmplLogin], data, funcs)
}

View File

@ -137,6 +137,9 @@ func CreateRenderer(pathPrefix string, staticDir http.FileSystem, cookieName str
"selectedGender": func(g int32) bool {
return false
},
"hasExternalLogin": func() bool {
return false
},
}
var err error
r.Renderer, err = renderer.NewRenderer(

View File

@ -36,7 +36,7 @@
{{end}}
</div>
{{if .LoginPolicy.AllowExternalIDP}}
{{if hasExternalLogin }}
<div class="actions idp-providers">
<p>{{t "Login.ExternalLogin"}}</p>