~sircmpwn/meta.sr.ht

ref: 72548bd7545f78670878667674cc7645835a17bd meta.sr.ht/metasrht/templates/user.html -rw-r--r-- 12.2 KiB
72548bd7Drew DeVault API: Updates per core-go auth changes 1 year, 1 month ago
                                                                                
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
{% extends "meta.html" %}
{% block title %}
<title>~{{user.username}} - {{cfg("sr.ht", "site-name")}} meta</title>
{% endblock %}
{% block content %}
<h3>~{{user.username}}</h3>
<div class="row">
  <section class="col-md-12">
    <dl class="row">
      <dt class="col-md-3">User ID</dt>
      <dd class="col-md-9">{{user.id}}</dd>
      <dt class="col-md-3">Email</dt>
      <dd class="col-md-9">
        <a href="mailto:{{user.email}}">{{user.email}}</a>
      </dd>
      <dt class="col-md-3">Registered</dt>
      <dd class="col-md-9">{{user.created | date}}</dd>
      <dt class="col-md-3">User type</dt>
      <dd class="col-md-9">{{user.user_type.value}}</dd>
      {% if user.user_type.value == "suspended" %}
      <dt class="col-md-3">Suspension Notice</dt>
      <dd class="col-md-9">{{user.suspension_notice}}</dd>
      {% endif %}

      {% if user.location %}
      <dt class="col-md-3">Location</dt>
      <dd class="col-md-9">{{user.location}}</dd>
      {% endif %}
      {% if user.url %}
      <dt class="col-md-3">URL</dt>
      <dd class="col-md-9">
        <a
          href="{{user.url}}"
          target="_blank"
          rel="me noopener noreferrer nofollow"
        >{{user.url}}</a>
      </dd>
      {% endif %}

      {% if cfg("meta.sr.ht::billing", "enabled") == "yes"
        and user.stripe_customer %}
      <dt class="col-md-3">Stripe customer</dt>
      <dd class="col-md-9">
        <a href="https://dashboard.stripe.com/customers/{{user.stripe_customer}}">
          {{user.stripe_customer}}
        </a>
      </dd>
      <dt class="col-md-3">Payment amount</dt>
      <dd class="col-md-9">
        ${{"{:.2f}".format(user.payment_cents / 100)}}
      </dd>
      <dt class="col-md-3">Payment interval</dt>
      <dd class="col-md-9">
        {{user.payment_interval.value}}
      </dd>
      <dt class="col-md-3">Payment due</dt>
      <dd class="col-md-9">{{user.payment_due | date}}</dd>
      {% endif %}
    </dl>
    {% if user.bio %}
    <blockquote>
      {{user.bio | md}}
    </blockquote>
    {% endif %}
    {% if reset_pending %}
    <div class="alert alert-warning">
      <a
        href="{{url_for("auth.reset_GET", token=user.reset_hash)}}"
        class="btn btn-link pull-right"
      >reset link</a>
      Password reset pending.
    </div>
    {% endif %}
    <form
      method="POST"
      action="{{url_for("users.set_user_type", username=user.username)}}"
      class="alert alert-info"
    >
      {{csrf_token()}}
      <button
        type="submit"
        class="btn btn-primary btn-sm pull-right"
      >
        Update
      </button>
      <select
        name="user_type"
        class="form-control"
        style="display: inline; width: inherit"
      >
        {% for type in [
          "unconfirmed", "active_non_paying", "active_free", "active_paying",
          "active_delinquent", "admin" ] %}
          <option
            value="{{type}}"
            {% if user.user_type.value == type %}
            selected
            {% endif %}
          >{{type}}</option>
        {% endfor %}
        {% if user.user_type.value == "suspended" %}
          {# You can remove this here, but not set it #}
          <option value="suspended" selected>suspended</option>
        {% endif %}
      </select>
    </form>
    {% if totp %}
    <form
      method="POST"
      action="{{url_for("users.user_disable_totp", username=user.username)}}"
      class="alert alert-warning"
    >
      {{csrf_token()}}
      <button type="submit" class="btn btn-link pull-right">
        Disable TOTP
      </button>
      This account has TOTP enabled.
    </form>
    {% endif %}
  </section>
</div>
<div class="row">
  <form
    class="col-md-12"
    action="{{url_for('.user_add_note', username=user.username)}}"
    method="POST"
  >
    <h3>User notes</h3>
    <div class="event-list">
      {% for note in user.notes %}
      <div class="event">
        {{note.note}}
        <span class="text-muted">{{note.created | date}}</span>
      </div>
      {% endfor %}
    </div>
    <div class="form-group">
      <textarea
        id="notes"
        name="notes"
        class="form-control {{valid.cls('notes')}}"
        rows="3"
      >{{notes if notes else ""}}</textarea>
      {{valid.summary('notes')}}
    </div>
    {{csrf_token()}}
    <button type="submit" class="btn btn-primary pull-right">
      Add note
      {{icon('caret-right')}}
    </button>
  </form>
</div>
<div class="row">
  <div class="col-md-12">
    {% if any(user.ssh_keys) %}
    <h3>SSH keys</h3>
    <table class="table">
      <thead>
        <tr>
          <th>Name</th>
          <th>Fingerprint</th>
          <th>Authorized</th>
          <th>Last Used</th>
        </tr>
      </thead>
      <tbody>
        {% for key in user.ssh_keys %}
        <tr>
          <td>{{key.comment}}</td>
          <td>
            <details>
              <summary>{{key.fingerprint}}</summary>
              <pre style="max-width: 600px">{{key.key}}</pre>
            </details>
          </td>
          <td>{{key.created|date}}</td>
          <td>{{key.last_used|date}}</td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
    {% endif %}
    {% if any(user.pgp_keys) %}
    <h3>PGP keys</h3>
    <table class="table">
      <thead>
        <tr>
          <th>Email</th>
          <th>Key ID</th>
          <th>Authorized</th>
        </tr>
      </thead>
      <tbody>
        {% for key in user.pgp_keys %}
        <tr>
          <td>{{key.email}}</td>
          <td>
            <details>
              <summary>{{key.key_id}}</summary>
              <pre style="max-width: 600px">{{key.key}}</pre>
            </details>
          </td>
          <td>{{key.created|date}}</td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
    {% endif %}
    {% if user.confirmation_hash %}
    <div class="alert alert-warning">
      <a
        href="{{url_for("auth.confirm_account", token=user.confirmation_hash)}}"
        class="btn btn-link pull-right"
      >confirmation link</a>
      This account is pending confirmation.
    </div>
    {% endif %}
  </div>
</div>
<div class="row">
  <form
    class="col-md-12"
      method="POST"
      action="{{url_for("users.user_invoice", username=user.username)}}"
    >
      <h3>Issue account credit</h3>
      {{csrf_token()}}
      <div class="row">
        <div class="form-group col-md-6">
          <label for="amount">Amount (in dollars)</label>
          <input
            type="number"
            placeholder="Amount"
            class="form-control"
            id="amount"
            name="amount"
            value="20" />
        </div>
        <div class="form-group col-md-6">
          <label for="comment">Valid thru</label>
          <input
            type="date"
            class="form-control"
            name="valid_thru"
            value="{{one_year.strftime("%Y-%m-%d")}}" />
        </div>
      </div>
      <div class="form-group">
        <label for="source">Source ("paid with..." in billing UI)</label>
        <input
          type="text"
          placeholder="e.g. 'PayPal'"
          class="form-control"
          name="source" />
      </div>
      <button type="submit" class="btn btn-primary pull-right">
        Issue invoice
        {{icon('caret-right')}}
      </button>
  </form>
</div>
<div class="row">
  <form
    class="col-md-12"
      method="POST"
      action="{{url_for("users.user_suspend", username=user.username)}}"
    >
      <h3>Suspend account</h3>
      {{csrf_token()}}
      <div class="form-group">
        <input
          type="text"
          placeholder="Suspension reason (shown to user)"
          class="form-control"
          name="reason" />
      </div>
      <button type="submit" class="btn btn-danger pull-right">
        Suspend user
        {{icon('caret-right')}}
      </button>
  </form>
</div>
<div class="row">
  <section class="col-md-12">
    <h3>Audit Log</h3>
    <table class="table">
      <thead>
        <tr>
          <th>IP Address</th>
          <th>Host</th>
          <th>Details</th>
          <th>Date</th>
        </tr>
      </thead>
      <tbody>
        {% for log in audit_log %}
        <tr>
          <td>{{log.ip_address}}</td>
          <td>{{rdns.get(log.ip_address.exploded, "unknown")}}</td>
          <td>{{log.details or log.event_type}}</td>
          <td>{{log.created | date }}</td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </section>
</div>
<div class="row">
  <div class="col-md-12 event-list">
    <section>
      <h3>Personal Access Tokens</h3>
      <table class="table">
        <thead>
          <tr>
            <th>Comment</th>
            <th>Issued</th>
            <th>Expires</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for token in personal_tokens %}
          <tr>
            <td>{{ token.comment }}</td>
            <td>{{ token.issued | date }}</td>
            <td>{{ token.expires | date }}</td>
            <td style="width: 6rem">
              <a
                href="{{url_for('oauth2.personal_token_revoke_GET',
                  token_id=token.id)}}"
                class="btn btn-danger btn-fill"
              >Revoke</a>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
    <section>
      <h3>Authorized Clients</h3>
      <table class="table">
        <thead>
          <tr>
            <th>Service</th>
            <th>Operator</th>
            <th>Issued</th>
            <th>Expires</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for grant in oauth_grants %}
          <tr>
            <td>
              {# lol this hack is awful #}
              <a
                href="{{grant.client.url}}"
                rel="noopener"
              >{{ grant.client.name }}</a>
              <a
                href="{{grant.client.url}}"
                rel="noopener"
              >{{icon('external-link-alt')}}</a>
            </td>
            <td>{{grant.client.owner.canonicalName}}</td>
            <td>{{grant.issued | date}}</td>
            <td>{{grant.expires | date}}</td>
            <td style="width: 6rem">
              <a
                href="{{url_for("oauth2.bearer_token_revoke_GET",
                  token_hash=grant.tokenHash)}}"
                class="btn btn-danger btn-fill"
              >Revoke</a>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
    <section>
      <h3>Registered Clients</h3>
      <table class="table">
        <thead>
          <tr>
            <th>Name</th>
            <th>Client ID</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for client in oauth_clients %}
          <tr>
            <td>
              {# lol this hack is awful #}
              <a
                href="{{client.url}}"
                rel="noopener"
              >{{ client.name }}</a>
              <a
                href="{{client.url}}"
                rel="noopener"
              >{{icon('external-link-alt')}}</a>
            </td>
            <td>{{ client.uuid }}</td>
            <td style="width: 6rem">
              <a
                href="{{url_for('oauth2.manage_client_GET', uuid=client.uuid)}}"
                class="btn btn-default btn-fill"
              >Manage {{icon('caret-right')}}</a>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </section>
    <section>
      <h3>Invoices</h3>
      <div class="event-list">
        {% for invoice in invoices %}
        <div class="event invoice">
          <h4>
            <small class="text-success" style="margin-left: 0">
              {{icon('check')}}
            </small>
            ${{"{:.2f}".format(invoice.cents/100)}}
            <small>
              with {{invoice.source}}
            </small>
            <small>
              <a
                class="pull-right"
                href="{{url_for("billing.invoice_GET", invoice_id=invoice.id)}}"
              >Export as PDF</a>
            </small>
          </h4>
          <p>
            Paid {{invoice.created | date}}<br />
            Valid for service until {{invoice.valid_thru | date}}
            {% if invoice.comment %}
            <br />
            {{invoice.comment}}
            {% endif %}
          </p>
        </div>
        {% endfor %}
      </div>
    </section>
</div>
{% endblock %}