1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
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
|
-- vim: ft=terra
local pstr = lib.mem.ptr(int8)
local P = lib.str.plit
local terra
login_form(co: &lib.srv.convo, user: &lib.store.actor, creds: &lib.store.credset, msg: pstr)
var doc = [lib.srv.convo.page] {
title = lib.str.plit 'instance logon';
class = lib.str.plit 'login';
cache = false;
}
if user == nil then
var form = data.view.login_username {
loginmsg = msg;
}
if form.loginmsg.ptr == nil then
form.loginmsg = lib.str.plit 'identify yourself for access to this instance.'
end
doc.body = form:tostr()
elseif creds:sz() == 0 then
co:complain(403,'access denied','your host is not eligible to authenticate as this user')
return
elseif creds:sz() == 1 then
if creds.trust() then
................................................................................
end
var ch = data.view.login_challenge {
handle = user.handle;
name = lib.coalesce(user.nym, user.handle);
}
if creds.pw() then
ch.challenge = P'enter the password associated with your account'
ch.label = P'password'
ch.method = P'pw'
ch.auto = P'current-password';
elseif creds.otp() then
ch.challenge = P'enter a valid one-time password for your account'
ch.label = P'OTP code'
ch.method = P'otp'
ch.auto = P'one-time-code';
elseif creds.challenge() then
ch.challenge = P'sign the challenge token: <code>...</code>'
ch.label = P'digest'
ch.method = P'challenge'
ch.auto = P'one-time-code';
else
co:complain(500,'login failure','unknown login method')
return
end
doc.body = ch:tostr()
else
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
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
|
-- vim: ft=terra
local pstr = lib.mem.ptr(int8)
local terra
login_form(co: &lib.srv.convo, user: &lib.store.actor, creds: &lib.store.credset, msg: pstr)
var doc = [lib.srv.convo.page] {
title = 'instance logon';
class = 'login';
cache = false;
}
if user == nil then
var form = data.view.login_username {
loginmsg = msg;
}
if form.loginmsg.ptr == nil then
form.loginmsg = 'identify yourself for access to this instance.'
end
doc.body = form:tostr()
elseif creds:sz() == 0 then
co:complain(403,'access denied','your host is not eligible to authenticate as this user')
return
elseif creds:sz() == 1 then
if creds.trust() then
................................................................................
end
var ch = data.view.login_challenge {
handle = user.handle;
name = lib.coalesce(user.nym, user.handle);
}
if creds.pw() then
ch.challenge = 'enter the password associated with your account'
ch.label = 'password'
ch.method = 'pw'
ch.auto = 'current-password';
elseif creds.otp() then
ch.challenge = 'enter a valid one-time password for your account'
ch.label = 'OTP code'
ch.method = 'otp'
ch.auto = 'one-time-code';
elseif creds.challenge() then
ch.challenge = 'sign the challenge token: <code>...</code>'
ch.label = 'digest'
ch.method = 'challenge'
ch.auto = 'one-time-code';
else
co:complain(500,'login failure','unknown login method')
return
end
doc.body = ch:tostr()
else
|