OAuth

/views/vauth/Authentication.html (1.8 KB)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{% import (
"{{{ .Package }}}/app"
"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/lib/auth"
"{{{ .Package }}}/views/components"
) %}

{% func Authentication(as *app.State, ps *cutil.PageState) %}
{%- code
prvs, err := as.Auth.Providers(ps.Logger)
if err != nil {
panic(err)
}
-%}
<div class="card">
<div class="right"><a href="#modal-available"><button type="button">Available</button></a></div>
<h3>{%= components.SVGRefIcon(`profile`, ps) %}Authentication</h3>
{%- if len(prvs) == 0 -%}
<em class="mt">no authentication providers configured, why not <a href="#modal-available">add one</a>?</em>
{%- else -%}
<table class="mt">
{%- for _, prv := range prvs -%}
<tr><td><a href="/auth/{%u prv.ID %}?refer={%u `/admin` %}">{%s auth.AvailableProviderNames[prv.ID] %}</a></td></tr>
{%- endfor -%}
</table>
{%- endif -%}
</div>

<div id="modal-available" class="modal" style="display: none;">
<a class="backdrop" href="#"></a>
<div class="modal-content">
<div class="modal-header">
<a href="#" class="modal-close">×</a>
<h2>Available Authentication Providers</h2>
</div>
<div class="modal-body">
<table>
{%- for _, x := range auth.AvailableProviderKeys -%}
<tr>
{%- if prvs.Contains(x) -%}
<td class="nowrap"><em>{%s auth.AvailableProviderNames[x] %}</em></td>
<td><em>{%s auth.ProviderUsage(x, prvs.Contains(x)) %}</em></td>
{%- else -%}
<td class="nowrap">{%s auth.AvailableProviderNames[x] %}</td>
<td>{%s auth.ProviderUsage(x, prvs.Contains(x)) %}</td>
{%- endif -%}
</tr>
{%- endfor -%}
</table>
</div>
</div>
</div>
{% endfunc %}