Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
153 lines (143 sloc) 4.21 KB
[[@Windows,txDefs,txSession,DataLank,xxmString]][[!var
url,uname,sid,x,umsg:string;
ntauth:boolean;
qr:TQueryResult;
sc:TStringContext;
i:integer;
]][[
sid:=Context.SessionID;
if UseNTAuth then
uname:=Context.ContextString(csAuthUser)
else
uname:='';
ntauth:=uname<>'';
url:=Context['url'].Value;
umsg:='';
if ntauth then
qr:=TQueryResult.Create(Session.DbCon,'SELECT id, uid, email, 0 AS isanon FROM Usr WHERE auth=?',[uname])
else
begin
qr:=nil;//default
uname:=Context['username'].Value;
if uname<>'' then
begin
x:=Context[sid].Value;
if x<>'' then //if IsValidPassword(x) then
begin
qr:=TQueryResult.Create(Session.DbCon,'SELECT id, uid, email, pwd, salt, 0 AS isanon FROM Usr WHERE login=?',[uname]);
while qr.Read and (qr.GetStr('pwd')<>PasswordToken(qr.GetStr('salt'),x)) do ;
end;
end;
end;
if qr<>nil then
try
if qr.EOF then
begin
umsg:='Unknown username or incorrect password.';
Session.LogonAttemptCheck;
end
else
begin
Session.LoadUser(qr);
if Context['autologon'].AsInteger=1 then
begin
Session.DbCon.BeginTrans;
try
i:=Session.DbCon.Insert('Usl',
['usr_id',qr['id']
,'address',Context.ContextString(csRemoteAddress)
,'agent',Context.ContextString(csUserAgent)
,'c_ts',VNow
],'id');
NewAutoLogonToken(Context,i);
Session.DbCon.CommitTrans;
except
Session.DbCon.RollbackTrans;
raise;
end;
end;
if url='' then
Context.Redirect('/Default.xxm',true)
else
Context.Redirect(url,false);
end;
finally
qr.Free;
end;
Context.Include('dHead.xxmi',['Logon']);
if ntauth then
begin
i:=1;
while (i<Length(uname)) and (uname[i]<>'\') do inc(i);
if (i<Length(uname)) then uname:=Copy(uname,i+1,Length(uname)-i);
if Context['sendmail'].AsInteger=1 then
begin
//send mail
sc:=TStringContext.Create(Context,Self);
try
sc.AutoEncoding:=aeIso8859;
sc.Include('LogonMail_NTAuth.xxmi',Values,Objects);
sc.SaveToFile('C:\InetPub\mailroot\PickUp\txNTauth_'+FormatDateTime('yyyymmddhhnnss',Now)+'.eml');
finally
sc.Free;
end;
<<h2>Unknown user</h2>
<p>Mail sent.</p>>
end
else
begin
<<h2>Unknown user</h2>
<p>An NT-account name has been found, but no credentials are provided in the database for your NT-account.</p>
<p>If you would like to send a mail to the system's administrator(s) to request your NT-account information be added, please fill out this form:</p>
[[#txForm('Logon.xxm',['sendmail',1,'url',url])]]
<dl>
<dt>Your name</dt><dd><input type="text" name="name" id="username" value="[[=TryGetUserName(uname)]]" size="30" /></dd>
<dt>Request comment (optional)</dt><dd><textarea name="comment" cols="30" rows="5" style="width:100%;" wrap="soft"></textarea></dd>
</dl>
[[#txFormButton]]
</form>
<script><!--
$("#username")[0].focus();
//--></script>>
end;
end
else
begin
<<h2>Logon</h2>>
if Context['x'].AsInteger=1 then
begin
umsg:='Operation not allowed as anonymous user, please sign in or sign up.';
url:=Context.ContextString(csReferer);
end;
if umsg<>'' then
begin
<<p class="information">>=umsg<</p>>
end;
if Session.IsAnonymous then
begin
]]
[[#txForm('Logon.xxm',[])]]
<dl>
<dt>User name</dt><dd><input type="text" id="username" value="[[=uname]]" name="username" size="20" /></dd>
<dt>Password</dt><dd><input type="password" name="[[=sid]]" value="" size="20" /></dt>
</dl>
<input type="hidden" name="url" value="[[=url]]" />
[[#txFormButton]]
&nbsp;
<input type="checkbox" name="autologon" value="1" id="autologon1" />
<label for="autologon1">log on automatically on this computer</label>
</form>
<script><!--
$("#username")[0].focus();
//--></script>
<p><a href="fLogonPwd.xxm">I forgot my password...</a></p>
<p><a href="fLogon.xxm?url=[[=url]]">I'm a new user...</a></p>>
end
else
begin
<<p>You are already logged on.<br />
<a href="Users.xxm">Account</a><br />
<a href="Logoff.xxm">Log off</a></p>>
end;
end;
Context.Include('dFoot.xxmi');