forked from rejetto/hfs2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newuserpassDlg.pas
90 lines (74 loc) · 2.38 KB
/
newuserpassDlg.pas
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
{
Copyright (C) 2002-2012 Massimo Melina (www.rejetto.com)
This file is part of HFS ~ HTTP File Server.
HFS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
HFS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with HFS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit newuserpassDlg;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, utilLib;
type
TnewuserpassFrm = class(TForm)
userBox: TLabeledEdit;
pwdBox: TLabeledEdit;
pwd2Box: TLabeledEdit;
okBtn: TButton;
resetBtn: TButton;
procedure okBtnClick(Sender: TObject);
procedure resetBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
function prompt(var usr,pwd:string):boolean;
end;
var
newuserpassFrm: TnewuserpassFrm;
implementation
{$R *.dfm}
procedure TnewuserpassFrm.okBtnClick(Sender: TObject);
var
error: string;
begin
userBox.text:=trim(userBox.text);
pwdBox.text:=trim(pwdBox.text);
error:='';
if (userBox.text > '') and not validUsername(userBox.Text)
or (pwdBox.text > '') and not validUsername(pwdBox.text) then
error:='The characters below are not allowed'#13'/\:?*"<>|;&&@'
else if (pwdBox.text > '') and (userBox.text = '') then
error:='User is mandatory'
else if pwdBox.text <> pwd2Box.text then
error:='The two passwords you entered don''t match';
if error = '' then ModalResult:=mrOk
else msgDlg(error, MB_ICONERROR);
end;
procedure TnewuserpassFrm.resetBtnClick(Sender: TObject);
begin
userBox.text:='';
pwdBox.text:='';
pwd2Box.text:='';
end;
procedure TnewuserpassFrm.FormShow(Sender: TObject);
begin userBox.SetFocus() end;
function TnewuserpassFrm.prompt(var usr,pwd:string):boolean;
begin
userBox.Text:=usr;
pwdBox.text:=pwd;
pwd2Box.text:=pwd;
result:= ShowModal() = mrOk;
usr:=userBox.Text;
pwd:=pwdBox.text;
end;
end.