@@ -798,6 +798,29 @@ final class LoginHandler extends Base
798
798
*/
799
799
800
800
use validLogin, validPassword;
801
+
802
+ /**
803
+ * @param array $post is users input
804
+ *
805
+ * @return void
806
+ */
807
+ public function __construct ( $ post , $ id )
808
+ {
809
+ parent ::__construct ( $ post );
810
+
811
+ /**
812
+ * @var object
813
+ */
814
+ $ this ->user = R::findOne ( 'users ' , 'login = ? ' , array ( $ this ->login ) );
815
+
816
+ if ( !$ this ->user )
817
+ {
818
+ $ this ->user = R::findOne ( 'users ' , 'email = ? ' , array ( $ this ->login ) );
819
+ } else
820
+ {
821
+ $ this ->errors [] = array ( 'User not found! ' );
822
+ }
823
+ }
801
824
802
825
/**
803
826
* Checking login for valid and commit errors, if any.
@@ -814,28 +837,11 @@ public function isValid()
814
837
$ this ->errors [] = self ::isLogin ( $ this ->login );
815
838
}
816
839
817
- $ user = R::findOne ( 'users ' , 'login = ? ' , array ( $ this ->login ) );
818
- if ( !$ user )
819
- {
820
- $ user = R::findOne ( 'users ' , 'email = ? ' , array ( $ this ->login ) );
821
- }
822
-
823
840
if ( self ::isPassword ( $ this ->password ) )
824
841
{
825
842
$ this ->errors [] = self ::isPassword ( $ this ->password );
826
843
}
827
844
828
- if ( $ user )
829
- {
830
- if ( !password_verify ( $ this ->password , $ user ->password ) )
831
- {
832
- $ this ->errors [] = array ( 'Password is incorrect! ' );
833
- }
834
- } else
835
- {
836
- $ this ->errors [] = array ( 'User not found! ' );
837
- }
838
-
839
845
return $ this ->errors ;
840
846
}
841
847
@@ -846,7 +852,7 @@ public function isValid()
846
852
*/
847
853
protected function showSuccess ( $ template )
848
854
{
849
- $ _SESSION ['user ' ] = $ user ;
855
+ $ _SESSION ['user ' ] = $ this -> user ;
850
856
851
857
load_template ( $ template , array (
852
858
'message_color ' => 'green ' ,
0 commit comments