1212
1313class AutoLoginComponent extends Component {
1414
15- public $ components = ['Cookie ' , ' Auth ' ];
15+ public $ components = ['Cookie ' ];
1616 public $ request ;
1717 public $ settings = [];
1818 protected $ _defaultConfig = [
@@ -30,7 +30,7 @@ public function initialize(array $config)
3030 {
3131 parent ::initialize ([]);
3232 $ this ->configureCookie ();
33- if ($ this ->config ('autoLogin ' ) == true && ! $ this ->Auth ->user ()) {
33+ if ($ this ->config ('autoLogin ' ) == true && ! $ this ->_registry -> getController ()-> Auth ->user ()) {
3434 $ this ->restoreLoginFromCookie ();
3535 }
3636 }
@@ -60,11 +60,11 @@ public function restoreLoginFromCookie()
6060 $ controller = $ this ->_registry ->getController ();
6161 $ tempRequest = $ controller ->request ->data ;
6262 $ controller ->request ->data = $ loginData ;
63- $ user = $ this ->Auth ->identify ();
63+ $ user = $ controller ->Auth ->identify ();
6464 $ controller ->request ->data = $ tempRequest ;
6565
6666 if ($ user ) {
67- $ this ->Auth ->setUser ($ user );
67+ $ controller ->Auth ->setUser ($ user );
6868 return true ;
6969 }
7070
@@ -79,12 +79,12 @@ public function restoreLoginFromCookie()
7979 */
8080 public function setCookie ($ data = [])
8181 {
82+ $ controller = $ this ->_registry ->getController ();
8283 if (empty ($ data )) {
83- $ controller = $ this ->_registry ->getController ();
8484 $ data = $ controller ->request ->data ;
8585 }
8686 if (empty ($ data )) {
87- $ data = $ this ->Auth ->user ();
87+ $ data = $ controller ->Auth ->user ();
8888 }
8989 if (empty ($ data )) {
9090 return false ;
0 commit comments