AdminUserLoginRemote.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. namespace fecadmin\models\AdminUser;
  10. use fecadmin\models\AdminUser;
  11. use yii\base\Model;
  12. /**
  13. * @author Terry Zhao <2358269014@qq.com>
  14. * @since 1.0
  15. */
  16. class AdminUserLoginRemote extends Model{
  17. public $username;
  18. public $password;
  19. public $captcha;
  20. private $_admin_user;
  21. public function rules()
  22. {
  23. return [
  24. ['username', 'required'],
  25. ];
  26. }
  27. public function getAdminUser(){
  28. if($this->_admin_user === null){
  29. $this->_admin_user = AdminUser::findByUsername($this->username);
  30. }
  31. return $this->_admin_user;
  32. }
  33. public function login()
  34. {
  35. if ($this->validate()) {
  36. //return \Yii::$app->user->login($this->getAdminUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
  37. return \Yii::$app->user->login($this->getAdminUser(), 3600 * 24);
  38. } else {
  39. return false;
  40. }
  41. }
  42. }