Also i saw that my password is not marked with * but instead shows the characters
i cant seem to find what im doing wrong , i changed everything that should be changed.
var
sUser: string = '';
procedure frmLogin_OnShow (Sender: string; Action: string);
begin
frmLogin.edPassword.PasswordChar := '*';
frmLogin.bLogin.Default:=True;
end;
procedure Base_OnClose (Sender: string; Action: string);
begin
frmLogin.Close
end;
procedure frmLogin_bLogin_OnClick (Sender: string; var Cancel: boolean);
var
s: string;
begin
// SQL query for check user and password
s := VarToStr( SQLExecute('SELECT count(id) FROM users WHERE (login = ''' + frmLogin.edUser.Text + ''') AND (password = ''' + frmLogin.edPassword.Text + ''');') );
// if SQL query found login and password
if (s <> '0') and (s<>'') then
begin
sUser := frmLogin.edUser.Text; // remember username
// check admin rights
s := VarToStr( SQLExecute('SELECT administrator FROM users WHERE (login = ''' + sUser + ''');') );
if s='0' then Base.bUsers.Enabled := False; // if the user does not have administrator privileges, deactivate the button to create other users
// check permissions to read
s := VarToStr( SQLExecute('SELECT read FROM users WHERE (login = ''' + sUser + ''');') );
if s='0' then Base.edit.Enabled := False; // deactivate the button to edit the record
// check write permissions
s := VarToStr( SQLExecute('SELECT write FROM users WHERE (login = ''' + sUser + ''');') );
if s='0' then
begin
Base.New.Enabled := False; // deactivate the button to add the record
CharacterSheet.Save.Enabled := False; // deactivate the button to save the record
ActivityLog.save.Enabled := False;
Connections.save.Enabled := False;
end;
// check permission to delete
s := VarToStr( SQLExecute('SELECT remove FROM users WHERE (login = ''' + sUser + ''');') );
if s='0' then Base.delete.Enabled := False; // deactivate the button to delete the record
// check permission to search
s := VarToStr( SQLExecute('SELECT search FROM users WHERE (login = ''' + sUser + ''');') );
if s='0' then base.search.Enabled := False; // deactivate the button to search the records
frmLogin.Hide; // close login form
Base.Show;
end else MessageDlg('password is incorrect', mtError, mbOk, 0); // message if the password is incorrect
end;
begin
// Initial check whether there is a database administrator user
// if not, create an administrator with username admin and password admin
if VarToStr( SQLExecute('SELECT count(id) FROM users WHERE administrator=1;') ) = '0' then
begin
SQLExecute('INSERT INTO users (login, password, read, write, remove, search, administrator) VALUES ("admin", "admin", 1, 1, 1, 1, 1);');
frmLogin.edUser.Text := 'admin';
frmLogin.edPassword.Text := 'admin';
end;
end.