-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAuth.xxm
58 lines (54 loc) · 1.42 KB
/
Auth.xxm
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
[[@xxmSession,DataLank,base64,sha3,Windows,fCommon]][[!var
verb:WideString;
s:UTF8String;
db:TDataConnection;
]][[
verb:=Context.ContextString(csVerb);
if verb<>'POST' then
begin
if Context['key'].Value=Session.Key then
begin
s:=base64encode(SHA3_224(UTF8Encode(Format('[feederAutoLogon]%d:%d:%d:%d:%d:%d[%s]',
[GetTickCount
,GetCurrentThreadID
,GetCurrentProcessID
,integer(pointer(Self))
,integer(pointer(Context))
,Session.UserID
,Session.ID
]))));
db:=Session.Connection;
db.BeginTrans;
try
if Session.UserID=0 then
Session.UserID:=db.Insert('User',
['login',FormatDateTime('yyyymmddhhnnsszz',UtcNow)
,'name',''
,'email',''
,'created',double(UtcNow)
],'id');
db.Insert('UserLogon',
['user_id',Session.UserID
,'key',UTF8ToWideString(s)
,'created',double(UtcNow)
,'last',double(UtcNow)
,'address',Context.ContextString(csRemoteAddress)
,'useragent',Context.ContextString(csUserAgent)
]);
Context.SetCookie('feederAutoLogon',string(s),60*60*24*365,'','','',false,true);
db.CommitTrans;
except
db.RollbackTrans;
raise;
end;
end;
Context.Redirect('.',true);
end
else
AuthSession(
Context['key'].Value,
Context['login'].Value,
Context['name'].Value,
Context['email'].Value
);
Context.SendHTML('OK');