Updated 024 How to integrate the Create User Helper Method in your Components (markdown)

Amigo 2019-07-02 09:13:11 +02:00
parent a33a8bcbe7
commit b9bbc168e1
1 changed files with 5 additions and 7 deletions

@ -38,14 +38,12 @@ available in that class. It has been added as freebies and should not necessaril
### Get User Field
Here is 'getUser' when the page loads initially. The ID and the data are collected, get packed into some HTML and gets send off. This is a php site where this 'Create user' is being done. [00:15:16](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15rm16s) Then there is a Ajax site in Javascript. As the page loads in the JavaScript, you would get 'User' with the 'User ID' and the User ID from the field and then the data gets loaded. It shows the data which is loaded and that data can be edited except over here(Username). [00:15:51](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m51s) Numbers can not be added in the username but this(see video) may be done and it will update it and will indicate that it is updated. If there is a error with the email already used it will also show an error. This is how JavaScript had been set up. Javascript has been added to the View file. Here is 'getUser', and the function is displayed. [00:16:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m24s) Usually two functions are used in this case, one that are on standby and eventually setting up the data into the view. This is how the call structure would usually look in index.php?option=your components name, and the task which must go to the Ajax controller. This 'getUser' is the task. [00:16:54](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) Here can be stipulated in what format you would like the result set returned in. If the result set needs to be returned 'raw', which is sometimes the case, there is a 'raw' variable. [00:17:23](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m23s) The 'raw' variable may be set to true and it will give the results set just like that without braces around them, or a call back or anything. You will notice that when calls are made from JavaScript, it usually wants this call back to be added. If calls is made from other JavaScript libraries, you might just want the braces around it. But if it is wanted 'raw' which also is often the case, just add the variable 'raw' to the URL = true and then end up passing it back with 'json_encode'. NB.The format should remain 'json'. [00:17:56](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m56s)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Here is 'getUser' when the page loads initially. The ID and the data are collected, get packed into some HTML and gets send off. This is a PHP site where this 'Create user' is being done. [00:15:16](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15rm16s) Then there is a Ajax site in Javascript. As the page loads in the JavaScript, you would get 'User' with the 'User ID' and the User ID from the field and then the data gets loaded. It shows the data which is loaded and that data can be edited except over here(Username). [00:15:51](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m51s) Numbers can not be added in the username but this(see video) may be done and it will update it and will indicate that it is updated. If there is a error with the email already used it will also show an error. This is how JavaScript had been set up. Javascript has been added to the View file. Here is 'getUser', and the function is displayed. [00:16:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m24s) Usually two functions are used in this case, one that are on standby and eventually setting up the data into the view. This is how the call structure would usually look in index.php?option=your components name, and the task which must go to the Ajax controller. This 'getUser' is the task. [00:16:54](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) Here can be stipulated in what format you would like the result set returned in. If the result set needs to be returned 'raw', which is sometimes the case, there is a 'raw' variable. [00:17:23](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m23s) The 'raw' variable may be set to true and it will give the results set just like that without braces around them, or a call back or anything. You will notice that when calls are made from JavaScript, it usually wants this call back to be added. If calls is made from other JavaScript libraries, you might just want the braces around it. But if it is wanted 'raw' which also is often the case, just add the variable 'raw' to the URL = true and then end up passing it back with 'json_encode'. NB.The format should remain 'json'. [00:17:56](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m56s)
### Use Tokens
Always use a token. Have the token on the page. This token is necessary to prevent cross site scripting of course. I usually add the token to the page, through php. [00:18:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m28s) If you are working in a back end in the admin area, you don't need to have the token. It gets added to the page dynamically. Since we parsed the JavaScript areas. If we see token we actually know token is to be there and we add the token for you. Where as in the front end you must actually literally add the token. There was just too many reasons for us not to do the automation in the front end. You could literally change the variable name as well [00:19:03](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m03s) to something of your choice. Where as now it's just token, it's back end it's more secure. You need to always add a token to the request and check whether the token is there, if it's not that it wouldn't make a request at all. That's simply how we create a user and integrate the user concept within this component.
Always use a token. Have the token on the page. This token is necessary to prevent cross site scripting . It is recommended to add the token to the page, through PHP. [00:18:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m28s) If work is done in a back end in the admin area, it is not necessary to add the token as it gets added to the page dynamically, since the JavaScript areas had been parsed . If it shows 'token' then 'token' needs to be there and the token gets added. Whereas in the front end, 'token' should be added manually. For various reasons it had not been automated in the front-end so that the variable name can be changed as well. [00:19:03](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m03s) Whereas now it is just token, its back end is more secure. Always add a token to the request and check whether the token is there, if it is not, that it would not make a request at all. That is simply how a user is created and how the user concept is integrated within this component.
I hope that was helpful. I realize if you not that fluent in programming in JavaScript or in jQuery [00:19:41](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m41s) as well as in php. This might not fully resolved your questions. Like I said where the beginning of these tutorials I wasn't planning on making a component that is very easy to use, but rather a component that is very powerful to use. And leaving it up to you to decide how to implement this user integration is really the most powerful way of doing it. At least we are adding the the class which you can create the user. Even there you can go look at that class. [00:20:20](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m20s) If you feel my implementation needs some improvement, you can either shoot me a mail or you could fork this component builder on GitHub. Pull it down to your own repository. Make the changes push it back. The place inside of component builder where this class is constructed, [00:20:47](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m47s) is within the compilers files. Now the compiler have quite a few files and you need to do a search. Go to component builder, go to helper, and then use the compiler. Here is all its files. Do a search in here [00:21:09](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m09s) for the function create user. Just search for that and I'm sure you're fine it. It is in that area where you need to make the adaptation and the changes because it's dynamically added. It can't be edited right in the script, it needs to be edit in the function where we add it. Just go search those functions. [00:21:38](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m38s) That's how you create users and connect them to your components.
If you are not fully capable to do programming in JavaScript, jQuery or in PHP, this might not completely resolve your questions. This has not been meant to be a very user friendly component as such but rather a powerful tool to use.
[00:19:41](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m41s) At least this 'Class' had been added by which a user can be created. [00:20:20](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m20s) If VDM's implementation needs some improvement, Component Builder may be forked on GitHub and copied to your repository and the necessary changes be done to it before pushing it back again. [00:20:47](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m47s) The place in Component Builder where this 'Class' is constructed, is within the compilers files. Compiler have quite a few files and a search need to be done. Go to Component Builder, go to Helper, and then use the compiler. Here is all its files. A search can be done in there for the function 'Create user'. [00:21:09](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m09s) As it is dynamically added, it is in that area where the adaption and the changes needs to be done. It can't be edited right in the script, it needs to be edited in the function where it is added. Just search those functions. [00:21:38](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m38s) That's how to create users and connect them to components.