@@ -58,11 +58,10 @@ protected function _construct()
58
58
public function getFailuresCount ($ userName , $ userType )
59
59
{
60
60
$ select = $ this ->getConnection ()->select ();
61
- $ select ->columns ('failures_count ' )
62
- ->from ($ this ->getMainTable ())
63
- ->where ('user_login = ? AND user_type = ? ' , [$ userName , $ userType ]);
61
+ $ select ->from ($ this ->getMainTable (), 'failures_count ' )
62
+ ->where ('user_name = :user_name AND user_type = :user_type ' );
64
63
65
- return (int )$ this ->getConnection ()->fetchOne ($ select );
64
+ return (int )$ this ->getConnection ()->fetchOne ($ select, [ ' user_name ' => $ userName , ' user_type ' => $ userType ] );
66
65
}
67
66
68
67
/**
@@ -72,7 +71,7 @@ public function resetFailuresCount($userName, $userType)
72
71
{
73
72
$ this ->getConnection ()->delete (
74
73
$ this ->getMainTable (),
75
- ['user_login = ? ' => $ userName , 'user_type = ? ' => $ userType ]
74
+ ['user_name = ? ' => $ userName , 'user_type = ? ' => $ userType ]
76
75
);
77
76
}
78
77
@@ -83,15 +82,20 @@ public function incrementFailuresCount($userName, $userType)
83
82
{
84
83
$ date = (new \DateTime ())->setTimestamp ($ this ->dateTime ->gmtTimestamp ());
85
84
$ date ->add (new \DateInterval ('PT ' . $ this ->requestLogConfig ->getLockTimeout () . 'S ' ));
85
+ $ dateTime = $ date ->format (\Magento \Framework \Stdlib \DateTime::DATETIME_PHP_FORMAT );
86
+
86
87
$ this ->getConnection ()->insertOnDuplicate (
87
88
$ this ->getMainTable (),
88
89
[
89
- 'user_login ' => $ userName ,
90
+ 'user_name ' => $ userName ,
90
91
'user_type ' => $ userType ,
91
92
'failures_count ' => 1 ,
92
- 'lock_expires_at ' => $ date
93
+ 'lock_expires_at ' => $ dateTime
93
94
],
94
- ['failures_count ' => new \Zend_Db_Expr ('failures_count+1 ' ), 'lock_expires_at ' => $ date ]
95
+ [
96
+ 'failures_count ' => new \Zend_Db_Expr ('failures_count+1 ' ),
97
+ 'lock_expires_at ' => new \Zend_Db_Expr ("' " . $ dateTime . "' " )
98
+ ]
95
99
);
96
100
}
97
101
@@ -100,8 +104,10 @@ public function incrementFailuresCount($userName, $userType)
100
104
*/
101
105
public function clearExpiredFailures ()
102
106
{
107
+ $ date = (new \DateTime ())->setTimestamp ($ this ->dateTime ->gmtTimestamp ());
108
+ $ dateTime = $ date ->format (\Magento \Framework \Stdlib \DateTime::DATETIME_PHP_FORMAT );
103
109
$ select = $ this ->getConnection ()->select ();
104
- $ select ->from ($ this ->getMainTable ())->where ('lock_expires_at <= ? ' , $ this -> dateTime -> gmtTimestamp () );
110
+ $ select ->from ($ this ->getMainTable ())->where ('lock_expires_at <= ? ' , $ dateTime );
105
111
$ this ->getConnection ()->delete ($ select );
106
112
}
107
113
}
0 commit comments