DEV Community

Discussion on: Can you find the bug in this piece of php code? ๐Ÿคน

Collapse
 
8ivek profile image
Bivek • Edited

To make it more secure:
I would change following line:
if($params['pin'] != $user->getPin()) {

to:

if($params['pin'] !== $user->getPin()) {

Or

$user_input = (string) $params['pin'];

if($user_input != $user->getPin()) {

note: getPin => must always return string.

Collapse
 
nombrekeff profile image
Keff

Nice, thanks for the solutions! Never trust user input