Jump to content

Where to set a default Login / password ? (login form)


SergioFeitoza

Recommended Posts

1678468208_Defaultvalue.png.25d3b1e5fbbcecc07e1e83a4755f030b.pngSome time ago I set  a login name and a password as default to avoid to retype  everytime during my development.( see figure)

Now I am trying to remove them  to enable a normal use of typing both. However I do not  remember where I fixed these defaults

I think it is related to this cookie Inside my code

   edtLogin.Text := UniApplication.Cookies.GetCookie( '_loginname'  );

   edtSenha.Text := UniApplication.Cookies.GetCookie( '_pwd'  );

but the question is : where the default _loginname   and _pwd   came from ?   Can you help me?

I think I am not telling about the property “empty text”

Link to comment
Share on other sites

5 hours ago, SergioFeitoza said:

I think it is related to this cookie Inside my code

   edtLogin.Text := UniApplication.Cookies.GetCookie( '_loginname'  );

   edtSenha.Text := UniApplication.Cookies.GetCookie( '_pwd'  );

but the question is : where the default _loginname   and _pwd   came from ?

Hello,

UniMainModule -> OnBeforeLogin event ?

procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject;
  var Handled: Boolean);
var
  S1, S2 : string;
begin
  S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname'];
  S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd'];

  Handled := SameText(S1, 'demo') and SameText(S2, 'demo');

  if Handled then
    LoggedUser := S1;
end;

 

Link to comment
Share on other sites

8 hours ago, Sherzod said:

Hello,

UniMainModule -> OnBeforeLogin event ?


procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject;
  var Handled: Boolean);
var
  S1, S2 : string;
begin
  S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname'];
  S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd'];

  Handled := SameText(S1, 'demo') and SameText(S2, 'demo');

  if Handled then
    LoggedUser := S1;
end;

 

Thank you very much Sherzod  I understood the idea

Actually  this phase is in my code exactly as you wrote with the words"demo"

Question:  Should I write  instead of "demo" something like   ?

 S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname'];
    S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd'];

    Handled := SameText(S1, 'myDEFAULTLOGIN') and SameText(S2, 'myDEFAULTPASSWORD');

Or leave the  two spaces blank ?

Link to comment
Share on other sites

12 hours ago, Sherzod said:

Hello,

UniMainModule -> OnBeforeLogin event ?


procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject;
  var Handled: Boolean);
var
  S1, S2 : string;
begin
  S1 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_loginname'];
  S2 := (Sender as TUniGUISession).UniApplication.Cookies.Values['_pwd'];

  Handled := SameText(S1, 'demo') and SameText(S2, 'demo');

  if Handled then
    LoggedUser := S1;
end;

 

Hi Sherzod, thank you in advance for the frequent help

Now I went through the demo COOKIES and understood that what is missing to me is the concept of Cookies. I think that I understood something with the demo.

When I clicked the button GET ALL COOKIES I saw (see figure) that sergio and 123 (the default username and password) are there. So, it seems that in some moment of the past I created this and remained there.

I understood also that we can assign a expire date to the cookie.

Question 1:      How can I delete that cookie sergio 123 ?

Question 2:  about TUniGUIApplication Properties: (looking to TUniGUIApplication Properties  )    Is there a demo to enable me to understand how  to assign the application  “parameters” property ?

Link to comment
Share on other sites

Suggestion to ADD A BUTTON IN THE DEMO COOKIES

 

procedure TLoginForm.DeleteAllCookiesClick(Sender: TObject);
var
  I : Integer;
begin
  if UniApplication.Cookies.Count > 0 then
    for I := 0 to UniApplication.Cookies.Count - 1 do
       UniApplication.Cookies.SetCookie(UniApplication.Cookies[I],'',Date-1);
end;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...