Complete Login and Signup modules in MVT Framework#232
Conversation
…le to User module
|
|
||
| $_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING); | ||
| $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); | ||
| ?> |
There was a problem hiding this comment.
Please remove the closing PHP tag.
There was a problem hiding this comment.
And a php file should end with a single blank line.
There was a problem hiding this comment.
Can you please do the above two changes for all the php files.
There was a problem hiding this comment.
This was already done during the day. I just have to push the code. Thanks @prathmeshranaut
| <?php | ||
| class Authentication { | ||
| private $user; | ||
| public $user; |
There was a problem hiding this comment.
You should make this private and use getters to get this variable in any other file.
Think of this from a software design perspective. You would never want any other script to modify the user data in the authentication file.
There was a problem hiding this comment.
@prathmeshranaut Agreed, I will do this change. Thanks for pointing it out.
| return false; | ||
| public function __construct($email, $password) { | ||
| if (!$email || !$password) { | ||
| return NULL; |
There was a problem hiding this comment.
Instead of returning null in a constructor, throw an exception. This is sort of a standard behavior.
There was a problem hiding this comment.
I read it somewhere, it is advised to throw an exception when it is truly an error, here what I am doing is making sure that the object doesn't exist in case the email and password are not provided. Check this @prathmeshranaut
There was a problem hiding this comment.
Check the standard coding guidelines once.
| ) VALUES (?, ?, ?, ?, ?)" | ||
| ); | ||
| $stmt->bind_param ( | ||
| 'sssss', |
There was a problem hiding this comment.
Here I am using prepared statement which is designed for sending safe query to db server, this can be done by escaping user input which is not part of the real query, and also checking the query. This is what I have done.
|
|
||
| $_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING); | ||
| $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); | ||
| ?> |
There was a problem hiding this comment.
And a php file should end with a single blank line.
| @@ -1,10 +1,14 @@ | |||
| <?php | |||
| // mysqli connection | |||
| //require_once('includes/settings.php'); | |||
There was a problem hiding this comment.
Do not include dead codes in comments. Simply remove the LOCs which are not required.
There was a problem hiding this comment.
Are you talking about the commented code in line 3? Because I do not see any dead code. @MehaKaushik
There was a problem hiding this comment.
@MehaKaushik You have commented on the wrong section of the file. That's the old code, which I have already removed.

Hence, taking no action.
There was a problem hiding this comment.
Hey, sorry my bad. Thanks for correcting me.
| } else { | ||
| return NULL; | ||
| } | ||
| } |
There was a problem hiding this comment.
I do not think returning NULL is a good idea. Can we change it to something else?
There was a problem hiding this comment.
#232 (comment) Explained it here. This is the standard way of making sure that object does not exist. @MehaKaushik
| $stmt->close(); | ||
| return $affected; | ||
| } else { | ||
| return false; |
There was a problem hiding this comment.
Multiple return statements are tried to be avoided. But Sometimes they cannot be.
Here, the second return can be removed. Instead of going into "else", control would go out and meet the other "return" statement. (Logically, can remove one of the three, returns)
| <?php | ||
| $APPLICATION_DIR = $APPLICATION_DIR ?? str_replace('includes', '', dirname(__FILE__)); | ||
| spl_autoload_register(function ($class_name) { | ||
| global $APPLICATION_DIR; |
There was a problem hiding this comment.
According to PSR2 standards, opening braces of a method MUST go onto the next line. This should hold for functions also, can you please check and change accordingly.
There was a problem hiding this comment.
@MehaKaushik Checked with the documentation. This is a function and therefore braces should remain as it is. I have incorporated the changes for all methods and classes, and verified it with the php code sniffer.
|
@MehaKaushik @prathmeshranaut Done with all the required changes. |
| "twig/twig": "~2.0", | ||
| "twilio/sdk": "^5.10" | ||
| "twilio/sdk": "^5.10", | ||
| "squizlabs/php_codesniffer": "*" |
There was a problem hiding this comment.
Could you please move this to a require-dev block.
The following has been implemented and achieved in this section [ Trello Task ]
Testing Responsiveness: