Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
ea52bf26
Commit
ea52bf26
authored
Oct 19, 2016
by
Eric Chiang
Committed by
GitHub
Oct 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #623 from ericchiang/dev-port-oob-template
*: port oob template
parents
86b2d939
7084a801
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
2 deletions
+36
-2
handlers.go
server/handlers.go
+1
-2
templates.go
server/templates.go
+12
-0
templates_default.go
server/templates_default.go
+12
-0
oob.html
web/templates/oob.html
+11
-0
No files found.
server/handlers.go
View file @
ea52bf26
...
...
@@ -384,8 +384,7 @@ func (s *Server) sendCodeResponse(w http.ResponseWriter, r *http.Request, authRe
}
if
authReq
.
RedirectURI
==
redirectURIOOB
{
// TODO(ericchiang): Add a proper template.
fmt
.
Fprintf
(
w
,
"Code: %s"
,
code
.
ID
)
s
.
templates
.
oob
(
w
,
code
.
ID
)
return
}
q
.
Set
(
"code"
,
code
.
ID
)
...
...
server/templates.go
View file @
ea52bf26
...
...
@@ -15,6 +15,7 @@ const (
tmplApproval
=
"approval.html"
tmplLogin
=
"login.html"
tmplPassword
=
"password.html"
tmplOOB
=
"oob.html"
)
const
coreOSLogoURL
=
"https://coreos.com/assets/images/brand/coreos-wordmark-135x40px.png"
...
...
@@ -23,6 +24,7 @@ var requiredTmpls = []string{
tmplApproval
,
tmplLogin
,
tmplPassword
,
tmplOOB
,
}
// TemplateConfig describes.
...
...
@@ -106,6 +108,7 @@ func loadTemplates(config TemplateConfig) (*templates, error) {
loginTmpl
:
tmpls
.
Lookup
(
tmplLogin
),
approvalTmpl
:
tmpls
.
Lookup
(
tmplApproval
),
passwordTmpl
:
tmpls
.
Lookup
(
tmplPassword
),
oobTmpl
:
tmpls
.
Lookup
(
tmplOOB
),
},
nil
}
...
...
@@ -120,6 +123,7 @@ type templates struct {
loginTmpl
*
template
.
Template
approvalTmpl
*
template
.
Template
passwordTmpl
*
template
.
Template
oobTmpl
*
template
.
Template
}
type
connectorInfo
struct
{
...
...
@@ -175,6 +179,14 @@ func (t *templates) approval(w http.ResponseWriter, state, username, clientName
renderTemplate
(
w
,
t
.
approvalTmpl
,
data
)
}
func
(
t
*
templates
)
oob
(
w
http
.
ResponseWriter
,
code
string
)
{
data
:=
struct
{
TemplateConfig
Code
string
}{
t
.
globalData
,
code
}
renderTemplate
(
w
,
t
.
oobTmpl
,
data
)
}
// small io.Writer utilitiy to determine if executing the template wrote to the underlying response writer.
type
writeRecorder
struct
{
wrote
bool
...
...
server/templates_default.go
View file @
ea52bf26
...
...
@@ -313,6 +313,18 @@ var defaultTemplates = map[string]string{
</div>
{{ template "footer.html" . }}
`
,
"oob.html"
:
`{{ template "header.html" . }}
<div class="panel">
<h2 class="heading">Login Successful</h2>
Please copy this code, switch to your application and paste it there:
<br/>
<input type="text" value="{{ .Code }}" />
</div>
{{ template "footer.html" . }}
`
,
"password.html"
:
`{{ template "header.html" . }}
...
...
web/templates/oob.html
0 → 100644
View file @
ea52bf26
{{ template "header.html" . }}
<div
class=
"panel"
>
<h2
class=
"heading"
>
Login Successful
</h2>
Please copy this code, switch to your application and paste it there:
<br/>
<input
type=
"text"
value=
"{{ .Code }}"
/>
</div>
{{ template "footer.html" . }}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment