auth/web/authorize.qtpl.go

447 lines
9.9 KiB
Go
Raw Normal View History

// Code generated by qtc from "authorize.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line web/authorize.qtpl:1
package web
//line web/authorize.qtpl:1
import "source.toby3d.me/website/indieauth/internal/domain"
//line web/authorize.qtpl:3
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line web/authorize.qtpl:3
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line web/authorize.qtpl:3
2022-01-20 19:50:15 +00:00
type AuthorizePage struct {
BaseOf
2022-01-31 16:15:38 +00:00
CSRF []byte
Providers []*domain.Provider
Scope domain.Scopes
Client *domain.Client
2022-01-20 19:50:15 +00:00
Me *domain.Me
2022-01-31 16:15:38 +00:00
RedirectURI *domain.URL
CodeChallengeMethod domain.CodeChallengeMethod
ResponseType domain.ResponseType
CodeChallenge string
State string
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:17
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) StreamTitle(qw422016 *qt422016.Writer) {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:17
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:18
2022-01-20 19:50:15 +00:00
if p.Client.GetName() == "" {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:18
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:19
2022-01-20 19:50:15 +00:00
p.StreamT(qw422016, "Authorize %s", p.Client.GetName())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:19
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:20
2022-01-20 19:50:15 +00:00
} else {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:20
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:21
2022-01-20 19:50:15 +00:00
p.StreamT(qw422016, "Authorize application")
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:21
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:22
2022-01-20 19:50:15 +00:00
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:22
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) WriteTitle(qq422016 qtio422016.Writer) {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
qw422016 := qt422016.AcquireWriter(qq422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
p.StreamTitle(qw422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
qt422016.ReleaseWriter(qw422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) Title() string {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
qb422016 := qt422016.AcquireByteBuffer()
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
p.WriteTitle(qb422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
qs422016 := string(qb422016.B)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
qt422016.ReleaseByteBuffer(qb422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
return qs422016
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:23
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:25
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) StreamBody(qw422016 *qt422016.Writer) {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:25
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<header>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:27
2022-01-20 19:50:15 +00:00
if p.Client.GetLogo() != nil {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:27
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<img
alt="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:29
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetName())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:29
qw422016.N().S(`"
2022-01-20 19:50:15 +00:00
crossorigin="anonymous"
decoding="async"
height="140"
importance="high"
loading="lazy"
referrerpolicy="no-referrer-when-downgrade"
src="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:36
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetLogo().String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:36
qw422016.N().S(`"
2022-01-20 19:50:15 +00:00
width="140">
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:38
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:38
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<h2>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:41
2022-01-20 19:50:15 +00:00
if p.Client.GetURL() != nil {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:41
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<a href="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:42
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetURL().String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:42
2022-01-20 19:50:15 +00:00
qw422016.N().S(`">
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:43
2022-01-20 19:50:15 +00:00
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:43
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:44
2022-01-20 19:50:15 +00:00
if p.Client.GetName() != "" {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:44
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:45
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetName())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:45
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:46
2022-01-20 19:50:15 +00:00
} else {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:46
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:47
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.ID.String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:47
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:48
2022-01-20 19:50:15 +00:00
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:48
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:49
2022-01-20 19:50:15 +00:00
if p.Client.GetURL() != nil {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:49
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</a>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:51
2022-01-20 19:50:15 +00:00
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:51
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</h2>
</header>
<main>
<form
accept-charset="utf-8"
action="/api/authorize"
autocomplete="off"
enctype="application/x-www-form-urlencoded"
method="post"
novalidate="true"
target="_self">
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:65
2022-01-20 19:50:15 +00:00
if p.CSRF != nil {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:65
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<input
type="hidden"
name="_csrf"
value="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:69
2022-01-20 19:50:15 +00:00
qw422016.E().Z(p.CSRF)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:69
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:70
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:70
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:72
2022-01-20 19:50:15 +00:00
for key, val := range map[string]string{
"client_id": p.Client.ID.String(),
"redirect_uri": p.RedirectURI.String(),
"response_type": p.ResponseType.String(),
"state": p.State,
} {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:77
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<input
type="hidden"
name="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:80
2022-01-20 19:50:15 +00:00
qw422016.E().S(key)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:80
2022-01-20 19:50:15 +00:00
qw422016.N().S(`"
value="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:81
2022-01-20 19:50:15 +00:00
qw422016.E().S(val)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:81
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:82
2022-01-20 19:50:15 +00:00
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:82
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:84
2022-01-20 19:50:15 +00:00
if len(p.Scope) > 0 {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:84
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<fieldset>
<legend>`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:86
2022-01-20 19:50:15 +00:00
p.StreamT(qw422016, "Choose your scopes")
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:86
2022-01-20 19:50:15 +00:00
qw422016.N().S(`</legend>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:88
2022-01-20 19:50:15 +00:00
for _, scope := range p.Scope {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:88
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<div>
<label>
<input
type="checkbox"
name="scope[]"
value="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:94
2022-01-20 19:50:15 +00:00
qw422016.E().S(scope.String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:94
2022-01-20 19:50:15 +00:00
qw422016.N().S(`"
checked>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:97
2022-01-20 19:50:15 +00:00
qw422016.E().S(scope.String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:97
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</label>
</div>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:100
2022-01-20 19:50:15 +00:00
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:100
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</fieldset>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:102
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:102
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:104
2022-01-20 19:50:15 +00:00
if p.CodeChallenge != "" {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:104
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<input
type="hidden"
name="code_challenge"
value="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:108
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.CodeChallenge)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:108
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
<input
type="hidden"
name="code_challenge_method"
value="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:113
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.CodeChallengeMethod.String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:113
2022-01-20 19:50:15 +00:00
qw422016.N().S(`">
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:114
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:114
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:116
if p.Me != nil {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:116
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<input
type="hidden"
name="me"
value="`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:120
qw422016.E().S(p.Me.String())
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:120
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:121
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:121
qw422016.N().S(`
`)
//line web/authorize.qtpl:123
if len(p.Providers) > 0 {
//line web/authorize.qtpl:123
qw422016.N().S(`
<select
name="provider"
autocomplete
required>
`)
//line web/authorize.qtpl:129
for _, provider := range p.Providers {
//line web/authorize.qtpl:129
qw422016.N().S(`
<option
value="`)
//line web/authorize.qtpl:131
qw422016.E().S(provider.UID)
//line web/authorize.qtpl:131
qw422016.N().S(`"
`)
//line web/authorize.qtpl:132
if provider.UID == "mastodon" {
//line web/authorize.qtpl:132
qw422016.N().S(`selected`)
//line web/authorize.qtpl:132
}
//line web/authorize.qtpl:132
qw422016.N().S(`>
`)
//line web/authorize.qtpl:134
qw422016.E().S(provider.Name)
//line web/authorize.qtpl:134
qw422016.N().S(`
</option>
`)
//line web/authorize.qtpl:136
}
//line web/authorize.qtpl:136
qw422016.N().S(`
</select>
`)
//line web/authorize.qtpl:138
} else {
//line web/authorize.qtpl:138
qw422016.N().S(`
<input type="hidden" name="provider" value="direct">
`)
//line web/authorize.qtpl:140
}
//line web/authorize.qtpl:140
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<button
type="submit"
name="authorize"
value="deny">
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:147
p.StreamT(qw422016, "Deny")
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:147
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
</button>
2022-01-20 19:50:15 +00:00
<button
type="submit"
name="authorize"
value="allow">
2022-01-20 19:50:15 +00:00
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:155
p.StreamT(qw422016, "Allow")
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:155
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
</button>
</form>
</main>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) WriteBody(qq422016 qtio422016.Writer) {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
qw422016 := qt422016.AcquireWriter(qq422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
p.StreamBody(qw422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
qt422016.ReleaseWriter(qw422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
}
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) Body() string {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
qb422016 := qt422016.AcquireByteBuffer()
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
p.WriteBody(qb422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
qs422016 := string(qb422016.B)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
qt422016.ReleaseByteBuffer(qb422016)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
return qs422016
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:159
}