<div dir="ltr"><div dir="ltr">Hi Benoît,<br><br>Thank you for answering me.<br>Continuous between the lines, I hope that the mail does not become very long..</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El jue., 12 sept. 2019 a las 19:40, Benoît Minisini (<<a href="mailto:g4mba5@gmail.com">g4mba5@gmail.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Le 10/09/2019 à 17:09, Matias De lellis a écrit :<br>
> Hi all,<br>
> <br>
> As I comment in an previous email, the idea is make a pagekite <br>
> administration page, and I assumed that Gambas webform is a good<br>
> candidate. So, I started writing an example to internalize with him,<br>
> and I am very happy. =)<br>
> <br>
> I share a complete example of CRUD handling users. *<br>
> <a href="https://github.com/matiasdelellis/gambas3-crud-example" rel="noreferrer" target="_blank">https://github.com/matiasdelellis/gambas3-crud-example</a> * <br>
> <a href="https://github.com/matiasdelellis/gambas3-crud-example/releases/download/v0.1.1/WebformCrudExample-0.1.1.tar.gz" rel="noreferrer" target="_blank">https://github.com/matiasdelellis/gambas3-crud-example/releases/download/v0.1.1/WebformCrudExample-0.1.1.tar.gz</a><br>
><br>
>  The intial class is WebformLogin -Everything starts from there-, but<br>
>  there is a WebFormInstall that must be called once to build the<br>
> database.<br>
> <br>
> Based on this experience I ask some questions:<br>
> <br>
> 1. The type of database, name, etc, is fixed/hardcoded, but I would<br>
> like it to be configurable in WebFormInstall. Do you have any<br>
> suggestions? It must be written by WebformIntall and taked<br>
> automatically by WebDatabase.<br>
<br>
Store that in a configuration file using 'gb.settings'?<br></blockquote><div><br></div><div>Wow .. I spent long time thinking about environment variables, etc.,</div><div>and never thought about it. Great!</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> 1.1. This is annoying, but I ask you to do a quick look at the <br>
> WebDatabase.module to see if you believe it is well done, in<br>
> particular if they it is transparent to interact with the rest of the<br>
> classes, and if security consideration -AdminOrOwnRequired() and<br>
> AdminRequired subrutines- to admin task is sufficient.<br>
> <br>
<br>
As soon as you use the substitution methods to forge your requests, you <br>
should not have any problem of SQL injection.<br>
<br>
You use exceptions (Error.Raise) to check administrator rights. It's <br>
usually not a good idea. You should use return values, and keep <br>
exceptions for... exceptional things like errors.<br>
<br>
Another detail: you don't need to end your request strings with ';'.<br>
<br>
And you should explain on the pages how many characters are required in <br>
logins and passwords. Otherwise people have to read your code to know.<br></blockquote><div><br></div><div>Okay .. It all makes sense.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> 2. The values of inputs, positions, active WebForm, are all saved in<br>
>  Session, which is interesting, but these are accessible with the<br>
> inspector,<br>
<br>
Inspector? What are you talking about?<br></blockquote><div><br></div><div>Sorry.. Originally I thought I could find the passwords inside the html, but<br></div><div>it clearly doesn't happen.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> and a GET is emited with that data every time the focus<br>
> changes between the inputs. This is a local security problem that<br>
> would be good to improve.<br>
<br>
What do you suggest? What is the problem with sending to the server the <br>
contents of text fields?<br></blockquote><div><br></div><div>Well, The only problem is that it is a GET, therefore the password is sent<br>within the url, and would be accessible by anyone who manages the network.<br><br>Taking into account that now is easy to obtain legal ssl certificates, I guess</div><div>this is paranoid. But if the password is saved by the browser, just by clicking<br></div><div>on the filled in inputs, a GET is emited, where passwords are observed. Again,</div><div>paranoid, haha. IMHO It's something to improve, but of course with a very</div><div>low priority.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> 3. Related, upon requesting the page again, (Pressing F5), I would <br>
> expect this data to be cleaned, but I always get the previous data. I<br>
> can't abandon the session, due the active WebForm is saved there<br>
> too.<br>
<br>
I don't understand what you are talking about. Of course F5 does not <br>
clear the data. As everything is stored on the server, everything is <br>
refreshed on F5. What's the problem?<br></blockquote><div><br></div><div>Well, on a login page I would expect not to save it.</div><div>I guess I should do it by code, and clean this inputs when reload the page.</div><div><div>Maybe could add a property to do this automatically?</div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> 4. How to reuse js components?. In this example I use toastify to<br>
> show a simple notification.<br>
> <br>
>> Webform.AddJavascriptFile("toastify.js")<br>
> <br>
> It add the script from 'data' folder. Shouldn't it be in public?<br>
<br>
It's not needed, as the file is not directly sent to the client.<br>
<br>
All javascript files added by Webform.AddJavascriptFile() are <br>
concatenated and sent in one request to the client. The request is <br>
inserted in all HTML pages generated by 'gb.web.form' through a <script> <br>
markup in the <head> of the page.<br>
<br>
> <br>
> There is no equivalent for css?. The only way I found is to add <br>
> style.css file in public foloder to extend the default styles.<br>
> <br>
<br>
Yes, this is the only file supported by default. I could add the same <br>
mechanism that I made for javascript files. But you usually have several <br>
javascript files (so that you can separate your code), and only one <br>
stylesheet file. I was just lazy.<br></blockquote><div><br>Ok.. I almost proposed a pull request to add it, but since I discovered how</div><div>work and it seemed logical, I didn't send it. Maybe just need to document it</div><div>a bit.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>> WebForm._AddJavascript("Toastify({text: \'" & ("Done") & "\',<br>
> gravity: \'bottom\', close: true }).showToast();")<br>
> <br>
> This is correct to execute JS code?<br>
<br>
No, you must not call methods beginning with "_"!<br>
<br>
They are not part of the public interface, often don't do what you think <br>
they do, and can change at any moment.<br>
<br>
You can use the "Render" event to insert your own HTML (and so <br>
javascript) in a page.<br></blockquote><div><br></div><div>This is the only thing that is hard for me to understand.<br><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-">Do you suggest me that need to write the <botton> by hand, and write</span></span></div><div><span class="gmail-tlid-translation gmail-translation" lang="en"><span title="" class="gmail-">everything inside the onclick ()?. IMHO, It loses much of the grace of<br>working inside the server, since it would force me to validate within the<br>js, and it would be difficult for call a simple function.<br><br>I imagined something like WebTimer, but it always results in calling this<br>private function..</span></span></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> 5. How to publish the project?<br>
> <br>
>> GB_HTTPD_PORT=8080 gbx3 -H<br>
> <br>
> ...and an Apache reverse proxy form url to 8080 port?<br>
<br>
No, this is just for debugging.<br>
<br>
Make an executable. That executable is a CGI script that you must put in <br>
the suitable directories using the suitable configuration of your web <br>
server.<br></blockquote><div><br></div><div>I never work with CGI scripts. I'm going to investigate it better, and then try<br>to document everything,</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> I have many more doubts, but I guess this is enough for a first <br>
> consultation.. :sweet_smiley:<br>
> <br>
> Of course, thank you very much for all the development, and any<br>
> response..<br>
> <br>
> Ragards, Matias.<br>
> <br>
<br>
You're welcome.<br>
<br>
Regards,<br>
<br>
<br>
<br>
-- <br>
Benoît Minisini<br>
<br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</blockquote></div></div>