Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Complete Login and Signup modules in MVT Framework#232

Merged
MehaKaushik merged 16 commits into
systers:developfrom
fatimarafiqui:wip/auth
Jun 9, 2017
Merged

Complete Login and Signup modules in MVT Framework#232
MehaKaushik merged 16 commits into
systers:developfrom
fatimarafiqui:wip/auth

Conversation

@fatimarafiqui

@fatimarafiqui fatimarafiqui commented Jun 7, 2017

Copy link
Copy Markdown

The following has been implemented and achieved in this section [ Trello Task ]

  • User and Authentication class modules and methods
  • Validation of user data for login and signup
  • Added npm_module directory and setup of gulp for minification of stylesheets
  • AJAX handlers for proper authentication in login/signup
  • UI Enhancement of the complete login/signup and incorporating responsiveness.
  • Sanitisation of GET and POST data.
  • Rewritten myqli based on OOPs concept.
  • Updation of HOST to localhost root
  • Updating gitignore

loginsignupcomplete

Testing Responsiveness:

responsive

Comment thread includes/application.php Outdated

$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the closing PHP tag.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a php file should end with a single blank line.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please do the above two changes for all the php files.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already done during the day. I just have to push the code. Thanks @prathmeshranaut

Comment thread modules/Authentication.php Outdated
<?php
class Authentication {
private $user;
public $user;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prathmeshranaut Agreed, I will do this change. Thanks for pointing it out.

Comment thread modules/Authentication.php Outdated
return false;
public function __construct($email, $password) {
if (!$email || !$password) {
return NULL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning null in a constructor, throw an exception. This is sort of a standard behavior.

@fatimarafiqui fatimarafiqui Jun 7, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the standard coding guidelines once.

Comment thread modules/User.php Outdated
) VALUES (?, ?, ?, ?, ?)"
);
$stmt->bind_param (
'sssss',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread includes/application.php Outdated

$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a php file should end with a single blank line.

@@ -1,10 +1,14 @@
<?php
// mysqli connection
//require_once('includes/settings.php');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not include dead codes in comments. Simply remove the LOCs which are not required.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you talking about the commented code in line 3? Because I do not see any dead code. @MehaKaushik

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code in line 3

@fatimarafiqui fatimarafiqui Jun 7, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MehaKaushik You have commented on the wrong section of the file. That's the old code, which I have already removed.
screen shot 2017-06-07 at 23 03 55

Hence, taking no action.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry my bad. Thanks for correcting me.

Comment thread modules/User.php Outdated
} else {
return NULL;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think returning NULL is a good idea. Can we change it to something else?

@fatimarafiqui fatimarafiqui Jun 7, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#232 (comment) Explained it here. This is the standard way of making sure that object does not exist. @MehaKaushik

Comment thread modules/User.php Outdated
$stmt->close();
return $affected;
} else {
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MehaKaushik I will fix this.

Comment thread includes/application.php Outdated
<?php
$APPLICATION_DIR = $APPLICATION_DIR ?? str_replace('includes', '', dirname(__FILE__));
spl_autoload_register(function ($class_name) {
global $APPLICATION_DIR;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MehaKaushik Agree, will make the change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@fatimarafiqui

Copy link
Copy Markdown
Author

@MehaKaushik @prathmeshranaut Done with all the required changes.

Comment thread composer.json
"twig/twig": "~2.0",
"twilio/sdk": "^5.10"
"twilio/sdk": "^5.10",
"squizlabs/php_codesniffer": "*"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this to a require-dev block.

@MehaKaushik MehaKaushik merged commit 47cdca0 into systers:develop Jun 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants