Add ProviderName field; use in sign_in template

This commit is contained in:
Mike Bland 2015-03-31 12:59:07 -04:00
parent 0136ab01fd
commit 666e6ad436
5 changed files with 16 additions and 9 deletions

View File

@ -279,11 +279,13 @@ func (p *OauthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
rw.WriteHeader(code)
t := struct {
ProviderName string
SignInMessage string
CustomLogin bool
Redirect string
Version string
}{
ProviderName: p.provider.Data().ProviderName,
SignInMessage: p.SignInMessage,
CustomLogin: p.displayCustomLoginForm(),
Redirect: req.URL.RequestURI(),

View File

@ -13,6 +13,7 @@ type GoogleProvider struct {
}
func NewGoogleProvider(p *ProviderData) *GoogleProvider {
p.ProviderName = "Google"
if p.LoginUrl.String() == "" {
p.LoginUrl = &url.URL{Scheme: "https",
Host: "accounts.google.com",

View File

@ -11,6 +11,7 @@ import (
func newGoogleProvider() *GoogleProvider {
return NewGoogleProvider(
&ProviderData{
ProviderName: "",
LoginUrl: &url.URL{},
RedeemUrl: &url.URL{},
ProfileUrl: &url.URL{},
@ -20,6 +21,7 @@ func newGoogleProvider() *GoogleProvider {
func TestGoogleProviderDefaults(t *testing.T) {
p := newGoogleProvider()
assert.NotEqual(t, nil, p)
assert.Equal(t, "Google", p.Data().ProviderName)
assert.Equal(t, "https://accounts.google.com/o/oauth2/auth",
p.Data().LoginUrl.String())
assert.Equal(t, "https://accounts.google.com/o/oauth2/token",
@ -45,6 +47,7 @@ func TestGoogleProviderOverrides(t *testing.T) {
Path: "/oauth/profile"},
Scope: "profile"})
assert.NotEqual(t, nil, p)
assert.Equal(t, "Google", p.Data().ProviderName)
assert.Equal(t, "https://example.com/oauth/auth",
p.Data().LoginUrl.String())
assert.Equal(t, "https://example.com/oauth/token",

View File

@ -5,6 +5,7 @@ import (
)
type ProviderData struct {
ProviderName string
LoginUrl *url.URL
RedeemUrl *url.URL
ProfileUrl *url.URL

View File

@ -115,7 +115,7 @@ func getTemplates() *template.Template {
{{ if .SignInMessage }}
<p>{{.SignInMessage}}</p>
{{ end}}
<button type="submit" class="btn">Sign in with a Google Account</button><br/>
<button type="submit" class="btn">Sign in with a {{.ProviderName}} Account</button><br/>
</form>
</div>