auth/web/authorize.qtpl.go

441 lines
9.8 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/toby3d/auth/internal/domain"
)
//line web/authorize.qtpl:5
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line web/authorize.qtpl:5
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line web/authorize.qtpl:5
2022-01-20 19:50:15 +00:00
type AuthorizePage struct {
BaseOf
2022-01-31 16:15:38 +00:00
Scope domain.Scopes
CodeChallengeMethod domain.CodeChallengeMethod
ResponseType domain.ResponseType
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
Providers []*domain.Provider
CSRF []byte
CodeChallenge string
State string
}
//line web/authorize.qtpl:19
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) StreamTitle(qw422016 *qt422016.Writer) {
//line web/authorize.qtpl:19
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:20
2022-01-20 19:50:15 +00:00
if p.Client.GetName() == "" {
//line web/authorize.qtpl:20
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:21
2022-01-20 19:50:15 +00:00
p.StreamT(qw422016, "Authorize %s", p.Client.GetName())
//line web/authorize.qtpl:21
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:22
2022-01-20 19:50:15 +00:00
} else {
//line web/authorize.qtpl:22
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:23
2022-01-20 19:50:15 +00:00
p.StreamT(qw422016, "Authorize application")
//line web/authorize.qtpl:23
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:24
2022-01-20 19:50:15 +00:00
}
//line web/authorize.qtpl:24
qw422016.N().S(`
`)
//line web/authorize.qtpl:25
}
//line web/authorize.qtpl:25
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) WriteTitle(qq422016 qtio422016.Writer) {
//line web/authorize.qtpl:25
qw422016 := qt422016.AcquireWriter(qq422016)
//line web/authorize.qtpl:25
p.StreamTitle(qw422016)
//line web/authorize.qtpl:25
qt422016.ReleaseWriter(qw422016)
//line web/authorize.qtpl:25
}
//line web/authorize.qtpl:25
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) Title() string {
//line web/authorize.qtpl:25
qb422016 := qt422016.AcquireByteBuffer()
//line web/authorize.qtpl:25
p.WriteTitle(qb422016)
//line web/authorize.qtpl:25
qs422016 := string(qb422016.B)
//line web/authorize.qtpl:25
qt422016.ReleaseByteBuffer(qb422016)
//line web/authorize.qtpl:25
return qs422016
//line web/authorize.qtpl:25
}
//line web/authorize.qtpl:27
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) StreamBody(qw422016 *qt422016.Writer) {
//line web/authorize.qtpl:27
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<header>
`)
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:29
if p.Client.GetLogo() != nil {
2022-01-31 16:15:38 +00:00
//line web/authorize.qtpl:29
qw422016.N().S(`
<img class=""
2022-01-20 19:50:15 +00:00
crossorigin="anonymous"
decoding="async"
height="140"
importance="high"
loading="lazy"
referrerpolicy="no-referrer-when-downgrade"
src="`)
//line web/authorize.qtpl:37
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetLogo().String())
//line web/authorize.qtpl:37
qw422016.N().S(`"
alt="`)
//line web/authorize.qtpl:38
qw422016.E().S(p.Client.GetName())
//line web/authorize.qtpl:38
qw422016.N().S(`"
2022-01-20 19:50:15 +00:00
width="140">
`)
//line web/authorize.qtpl:40
}
//line web/authorize.qtpl:40
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
<h2>
`)
//line web/authorize.qtpl:43
2022-01-20 19:50:15 +00:00
if p.Client.GetURL() != nil {
//line web/authorize.qtpl:43
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<a href="`)
//line web/authorize.qtpl:44
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetURL().String())
//line web/authorize.qtpl:44
2022-01-20 19:50:15 +00:00
qw422016.N().S(`">
`)
//line web/authorize.qtpl:45
2022-01-20 19:50:15 +00:00
}
//line web/authorize.qtpl:45
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:46
2022-01-20 19:50:15 +00:00
if p.Client.GetName() != "" {
//line web/authorize.qtpl:46
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:47
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.GetName())
//line web/authorize.qtpl:47
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:48
2022-01-20 19:50:15 +00:00
} else {
//line web/authorize.qtpl:48
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:49
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.Client.ID.String())
//line web/authorize.qtpl:49
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:50
2022-01-20 19:50:15 +00:00
}
//line web/authorize.qtpl:50
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:51
2022-01-20 19:50:15 +00:00
if p.Client.GetURL() != nil {
//line web/authorize.qtpl:51
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</a>
`)
//line web/authorize.qtpl:53
2022-01-20 19:50:15 +00:00
}
//line web/authorize.qtpl:53
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</h2>
</header>
<main>
<form class=""
2022-01-20 19:50:15 +00:00
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
`)
//line web/authorize.qtpl:67
2022-01-20 19:50:15 +00:00
if p.CSRF != nil {
//line web/authorize.qtpl:67
qw422016.N().S(`
<input type="hidden"
2022-01-20 19:50:15 +00:00
name="_csrf"
value="`)
//line web/authorize.qtpl:70
2022-01-20 19:50:15 +00:00
qw422016.E().Z(p.CSRF)
//line web/authorize.qtpl:70
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:71
}
//line web/authorize.qtpl:71
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:73
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,
} {
//line web/authorize.qtpl:78
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
<input type="hidden"
2022-01-20 19:50:15 +00:00
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"
2022-01-20 19:50:15 +00:00
name="scope[]"
value="`)
//line web/authorize.qtpl:93
2022-01-20 19:50:15 +00:00
qw422016.E().S(scope.String())
//line web/authorize.qtpl:93
2022-01-20 19:50:15 +00:00
qw422016.N().S(`"
checked>
`)
//line web/authorize.qtpl:96
2022-01-20 19:50:15 +00:00
qw422016.E().S(scope.String())
//line web/authorize.qtpl:96
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</label>
</div>
`)
//line web/authorize.qtpl:99
2022-01-20 19:50:15 +00:00
}
//line web/authorize.qtpl:99
2022-01-20 19:50:15 +00:00
qw422016.N().S(`
</fieldset>
`)
//line web/authorize.qtpl:101
}
//line web/authorize.qtpl:101
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:103
2022-01-20 19:50:15 +00:00
if p.CodeChallenge != "" {
//line web/authorize.qtpl:103
qw422016.N().S(`
<input type="hidden"
2022-01-20 19:50:15 +00:00
name="code_challenge"
value="`)
//line web/authorize.qtpl:106
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.CodeChallenge)
//line web/authorize.qtpl:106
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
<input type="hidden"
2022-01-20 19:50:15 +00:00
name="code_challenge_method"
value="`)
//line web/authorize.qtpl:110
2022-01-20 19:50:15 +00:00
qw422016.E().S(p.CodeChallengeMethod.String())
//line web/authorize.qtpl:110
2022-01-20 19:50:15 +00:00
qw422016.N().S(`">
`)
//line web/authorize.qtpl:111
}
//line web/authorize.qtpl:111
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:113
if p.Me != nil {
//line web/authorize.qtpl:113
qw422016.N().S(`
<input type="hidden"
2022-01-20 19:50:15 +00:00
name="me"
value="`)
//line web/authorize.qtpl:116
qw422016.E().S(p.Me.String())
//line web/authorize.qtpl:116
qw422016.N().S(`">
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:117
}
//line web/authorize.qtpl:117
2022-01-31 16:15:38 +00:00
qw422016.N().S(`
`)
//line web/authorize.qtpl:119
2022-01-31 16:15:38 +00:00
if len(p.Providers) > 0 {
//line web/authorize.qtpl:119
2022-01-31 16:15:38 +00:00
qw422016.N().S(`
<select name="provider"
2022-01-31 16:15:38 +00:00
autocomplete
required>
`)
//line web/authorize.qtpl:124
2022-01-31 16:15:38 +00:00
for _, provider := range p.Providers {
//line web/authorize.qtpl:124
2022-01-31 16:15:38 +00:00
qw422016.N().S(`
<option value="`)
//line web/authorize.qtpl:125
2022-01-31 16:15:38 +00:00
qw422016.E().S(provider.UID)
//line web/authorize.qtpl:125
2022-01-31 16:15:38 +00:00
qw422016.N().S(`"
`)
//line web/authorize.qtpl:126
2022-01-31 16:15:38 +00:00
if provider.UID == "mastodon" {
//line web/authorize.qtpl:126
2022-01-31 16:15:38 +00:00
qw422016.N().S(`selected`)
//line web/authorize.qtpl:126
2022-01-31 16:15:38 +00:00
}
//line web/authorize.qtpl:126
2022-01-31 16:15:38 +00:00
qw422016.N().S(`>
`)
//line web/authorize.qtpl:128
2022-01-31 16:15:38 +00:00
qw422016.E().S(provider.Name)
//line web/authorize.qtpl:128
2022-01-31 16:15:38 +00:00
qw422016.N().S(`
</option>
`)
//line web/authorize.qtpl:130
2022-01-31 16:15:38 +00:00
}
//line web/authorize.qtpl:130
2022-01-31 16:15:38 +00:00
qw422016.N().S(`
</select>
`)
//line web/authorize.qtpl:132
2022-01-31 16:15:38 +00:00
} else {
//line web/authorize.qtpl:132
2022-01-31 16:15:38 +00:00
qw422016.N().S(`
<input type="hidden"
name="provider"
value="direct">
2022-01-31 16:15:38 +00:00
`)
//line web/authorize.qtpl:136
2022-01-31 16:15:38 +00:00
}
//line web/authorize.qtpl:136
qw422016.N().S(`
<button type="submit"
2022-01-20 19:50:15 +00:00
name="authorize"
value="deny">
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:142
p.StreamT(qw422016, "Deny")
//line web/authorize.qtpl:142
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
</button>
<button type="submit"
2022-01-20 19:50:15 +00:00
name="authorize"
value="allow">
2022-01-20 19:50:15 +00:00
`)
//line web/authorize.qtpl:149
p.StreamT(qw422016, "Allow")
//line web/authorize.qtpl:149
qw422016.N().S(`
2022-01-20 19:50:15 +00:00
</button>
</form>
</main>
`)
//line web/authorize.qtpl:153
}
//line web/authorize.qtpl:153
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) WriteBody(qq422016 qtio422016.Writer) {
//line web/authorize.qtpl:153
qw422016 := qt422016.AcquireWriter(qq422016)
//line web/authorize.qtpl:153
p.StreamBody(qw422016)
//line web/authorize.qtpl:153
qt422016.ReleaseWriter(qw422016)
//line web/authorize.qtpl:153
}
//line web/authorize.qtpl:153
2022-01-20 19:50:15 +00:00
func (p *AuthorizePage) Body() string {
//line web/authorize.qtpl:153
qb422016 := qt422016.AcquireByteBuffer()
//line web/authorize.qtpl:153
p.WriteBody(qb422016)
//line web/authorize.qtpl:153
qs422016 := string(qb422016.B)
//line web/authorize.qtpl:153
qt422016.ReleaseByteBuffer(qb422016)
//line web/authorize.qtpl:153
return qs422016
//line web/authorize.qtpl:153
}