@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | class User extends \yuncms\models\User |
42 | 42 | { |
43 | 43 | //场景定义 |
44 | - const SCENARIO_CREATE = 'create';//后台或控制台创建用户 |
|
45 | - const SCENARIO_UPDATE = 'update';//后台或控制台修改用户 |
|
46 | - const SCENARIO_REGISTER = 'basic_create';//邮箱注册 |
|
47 | - const SCENARIO_EMAIL_REGISTER = 'email_create';//邮箱注册 |
|
48 | - const SCENARIO_MOBILE_REGISTER = 'mobile_create';//手机号注册 |
|
49 | - const SCENARIO_SETTINGS = 'settings';//更新 |
|
50 | - const SCENARIO_CONNECT = 'connect';//账户链接或自动注册新用户 |
|
44 | + const SCENARIO_CREATE = 'create'; //后台或控制台创建用户 |
|
45 | + const SCENARIO_UPDATE = 'update'; //后台或控制台修改用户 |
|
46 | + const SCENARIO_REGISTER = 'basic_create'; //邮箱注册 |
|
47 | + const SCENARIO_EMAIL_REGISTER = 'email_create'; //邮箱注册 |
|
48 | + const SCENARIO_MOBILE_REGISTER = 'mobile_create'; //手机号注册 |
|
49 | + const SCENARIO_SETTINGS = 'settings'; //更新 |
|
50 | + const SCENARIO_CONNECT = 'connect'; //账户链接或自动注册新用户 |
|
51 | 51 | const SCENARIO_PASSWORD = 'password'; |
52 | 52 | |
53 | 53 | //头像 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function behaviors() |
71 | 71 | { |
72 | 72 | $behaviors = parent::behaviors(); |
73 | - return ArrayHelper::merge($behaviors,[ |
|
73 | + return ArrayHelper::merge($behaviors, [ |
|
74 | 74 | 'taggable' => [ |
75 | 75 | 'class' => TaggableBehavior::class, |
76 | 76 | 'tagValuesAsArray' => true, |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | static::SCENARIO_EMAIL_REGISTER => ['nickname', 'email', 'password'], |
94 | 94 | static::SCENARIO_MOBILE_REGISTER => ['mobile', 'password'], |
95 | 95 | static::SCENARIO_SETTINGS => ['username', 'email', 'password'], |
96 | - static::SCENARIO_CONNECT => ['nickname', 'email', 'password'],//链接账户密码可以为空邮箱可以为空 |
|
97 | - static::SCENARIO_PASSWORD => ['password'],//只修改密码 |
|
96 | + static::SCENARIO_CONNECT => ['nickname', 'email', 'password'], //链接账户密码可以为空邮箱可以为空 |
|
97 | + static::SCENARIO_PASSWORD => ['password'], //只修改密码 |
|
98 | 98 | ]); |
99 | 99 | } |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function rules() |
106 | 106 | { |
107 | - return ArrayHelper::merge(parent::rules(),[ |
|
107 | + return ArrayHelper::merge(parent::rules(), [ |
|
108 | 108 | // nickname rules |
109 | 109 | 'nicknameRequired' => ['nickname', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_CONNECT]], |
110 | 110 | // email rules |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | const GENDER_FEMALE = 0b10; |
53 | 53 | |
54 | 54 | //当前状态 |
55 | - const CURRENT_OTHER = 0b0;//其他 |
|
56 | - const CURRENT_WORK = 0b1;//正常工作 |
|
57 | - const CURRENT_FREELANCE = 0b10;//自由职业者 |
|
58 | - const CURRENT_START = 0b11;//创业 |
|
59 | - const CURRENT_OUTSOURCE = 0b100;//外包 |
|
60 | - const CURRENT_JOB = 0b101;//求职 |
|
61 | - const CURRENT_STUDENT = 0b110;//学生 |
|
55 | + const CURRENT_OTHER = 0b0; //其他 |
|
56 | + const CURRENT_WORK = 0b1; //正常工作 |
|
57 | + const CURRENT_FREELANCE = 0b10; //自由职业者 |
|
58 | + const CURRENT_START = 0b11; //创业 |
|
59 | + const CURRENT_OUTSOURCE = 0b100; //外包 |
|
60 | + const CURRENT_JOB = 0b101; //求职 |
|
61 | + const CURRENT_STUDENT = 0b110; //学生 |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @inheritdoc |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | [ |
101 | 101 | 'mobile', |
102 | 102 | 'yuncms\core\validators\MobileValidator', |
103 | - 'when' => function ($model) { |
|
103 | + 'when' => function($model) { |
|
104 | 104 | return $model->country == 'China'; |
105 | 105 | } |
106 | 106 | ], |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'rules' => [ |
54 | 54 | [ |
55 | 55 | 'allow' => true, |
56 | - 'actions' => ['profile', 'account', 'privacy', 'avatar', 'confirm', 'networks', 'disconnect','follower-tag'], |
|
56 | + 'actions' => ['profile', 'account', 'privacy', 'avatar', 'confirm', 'networks', 'disconnect', 'follower-tag'], |
|
57 | 57 | 'roles' => ['@'], |
58 | 58 | ], |
59 | 59 | ], |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | Yii::$app->response->format = Response::FORMAT_JSON; |
129 | 129 | $tagId = Yii::$app->request->post('tag_id', null); |
130 | 130 | if (($tag = Tag::findOne($tagId)) == null) { |
131 | - throw new NotFoundHttpException (); |
|
131 | + throw new NotFoundHttpException(); |
|
132 | 132 | } else { |
133 | 133 | /** @var \yuncms\user\models\User $user */ |
134 | 134 | $user = Yii::$app->user->identity; |
@@ -94,12 +94,12 @@ |
||
94 | 94 | 'emailRequired' => ['email', 'required'], |
95 | 95 | 'emailTrim' => ['email', 'filter', 'filter' => 'trim'], |
96 | 96 | 'emailPattern' => ['email', 'email'], |
97 | - 'emailUsernameUnique' => [['email', 'username'], 'unique', 'when' => function ($model, $attribute) { |
|
97 | + 'emailUsernameUnique' => [['email', 'username'], 'unique', 'when' => function($model, $attribute) { |
|
98 | 98 | return $this->user->$attribute != $model->$attribute; |
99 | 99 | }, 'targetClass' => User::class], |
100 | 100 | 'newPasswordLength' => ['new_password', 'string', 'min' => 6], |
101 | 101 | 'currentPasswordRequired' => ['current_password', 'required'], |
102 | - 'currentPasswordValidate' => ['current_password', function ($attr) { |
|
102 | + 'currentPasswordValidate' => ['current_password', function($attr) { |
|
103 | 103 | if (!PasswordHelper::validate($this->$attr, $this->user->password_hash)) { |
104 | 104 | $this->addError($attr, Yii::t('user', 'Current password is not valid')); |
105 | 105 | } |
@@ -74,7 +74,7 @@ |
||
74 | 74 | ], |
75 | 75 | |
76 | 76 | 'registrationPolicyRequired' => ['registrationPolicy', 'required', 'skipOnEmpty' => false, 'requiredValue' => true, |
77 | - 'message' => Yii::t('yuncms', 'By registering you confirm that you accept the Service Agreement and Privacy Policy.'),], |
|
77 | + 'message' => Yii::t('yuncms', 'By registering you confirm that you accept the Service Agreement and Privacy Policy.'), ], |
|
78 | 78 | ]; |
79 | 79 | } |
80 | 80 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'emailRequired' => ['email', 'required'], |
66 | 66 | 'emailPattern' => ['email', 'email'], |
67 | 67 | 'emailExist' => ['email', 'exist', 'targetClass' => User::class, 'message' => Yii::t('yuncms', 'There is no user with this email address')], |
68 | - 'emailUnconfirmed' => ['email', function ($attribute) { |
|
68 | + 'emailUnconfirmed' => ['email', function($attribute) { |
|
69 | 69 | $this->user = User::findByEmail($this->email); |
70 | 70 | if ($this->user !== null && $this->getSetting('enableConfirmation') && !$this->user->isEmailConfirmed) { |
71 | 71 | $this->addError($attribute, Yii::t('yuncms', 'You need to confirm your email address.')); |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | { |
86 | 86 | if ($this->validate()) { |
87 | 87 | /** @var UserToken $token */ |
88 | - $token = new UserToken([ 'user_id' => $this->user->id, 'type' => UserToken::TYPE_RECOVERY]); |
|
88 | + $token = new UserToken(['user_id' => $this->user->id, 'type' => UserToken::TYPE_RECOVERY]); |
|
89 | 89 | $token->save(false); |
90 | - $this->sendMessage($this->user->email,Yii::t('yuncms', 'Complete password reset on {0}', Yii::$app->name),'recovery',['user' => $this->user, 'token' => $token]); |
|
90 | + $this->sendMessage($this->user->email, Yii::t('yuncms', 'Complete password reset on {0}', Yii::$app->name), 'recovery', ['user' => $this->user, 'token' => $token]); |
|
91 | 91 | Yii::$app->session->setFlash('info', Yii::t('yuncms', 'An email has been sent with instructions for resetting your password')); |
92 | 92 | return true; |
93 | 93 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'emailRequired' => ['email', 'required'], |
52 | 52 | 'emailPattern' => ['email', 'email'], |
53 | 53 | 'emailExist' => ['email', 'exist', 'targetClass' => User::class], |
54 | - 'emailConfirmed' => ['email', function () { |
|
54 | + 'emailConfirmed' => ['email', function() { |
|
55 | 55 | if ($this->user != null && $this->user->isEmailConfirmed) { |
56 | 56 | $this->addError('email', Yii::t('user', 'This account has already been confirmed')); |
57 | 57 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | /** @var UserToken $token */ |
91 | 91 | $token = new UserToken(['user_id' => $this->user->id, 'type' => UserToken::TYPE_CONFIRMATION]); |
92 | 92 | $token->save(false); |
93 | - $this->sendMessage($this->user->email,Yii::t('yuncms', 'Confirm account on {0}', Yii::$app->name),'confirmation',['user' => $this->user, 'token' => $token]); |
|
93 | + $this->sendMessage($this->user->email, Yii::t('yuncms', 'Confirm account on {0}', Yii::$app->name), 'confirmation', ['user' => $this->user, 'token' => $token]); |
|
94 | 94 | Yii::$app->session->setFlash('info', Yii::t('yuncms', 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.')); |
95 | 95 | return true; |
96 | 96 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | //监听用户活动时间 |
29 | 29 | /** @var \yii\web\UserEvent $event */ |
30 | - $app->on(Application::EVENT_AFTER_REQUEST, function ($event) use ($app) { |
|
30 | + $app->on(Application::EVENT_AFTER_REQUEST, function($event) use ($app) { |
|
31 | 31 | if (!$app->user->isGuest && Yii::$app->has('queue')) { |
32 | 32 | //$app->user->identity->update |
33 | 33 | //记录最后活动时间 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | //监听用户登录事件 |
39 | 39 | /** @var \yii\web\UserEvent $event */ |
40 | - $app->user->on(User::EVENT_AFTER_LOGIN, function ($event) use ($app) { |
|
40 | + $app->user->on(User::EVENT_AFTER_LOGIN, function($event) use ($app) { |
|
41 | 41 | //记录最后登录时间记录最后登录IP记录登录次数 |
42 | 42 | Yii::$app->queue->push(new ResetLoginDataJob(['user_id' => $app->user->identity->getId(), 'ip' => Yii::$app->request->userIP])); |
43 | 43 | }); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | ], |
10 | 10 | 'components' => [ |
11 | 11 | 'cache' => [ |
12 | - 'keyPrefix' => 'web', //前缀 |
|
12 | + 'keyPrefix' => 'web', //前缀 |
|
13 | 13 | ], |
14 | 14 | 'user' => [ |
15 | 15 | 'identityClass' => yuncms\user\models\User::class, |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | 'secureProtocolHeaders' => [ |
23 | 23 | 'X-Forwarded-Proto' => ['https'], // Common |
24 | 24 | 'Front-End-Https' => ['on'], // Microsoft |
25 | - 'X-Client-Scheme' => ['https'],// Aliyun CDN |
|
25 | + 'X-Client-Scheme' => ['https'], // Aliyun CDN |
|
26 | 26 | 'X-Client-Proto' => ['https'], |
27 | 27 | ], |
28 | 28 | 'ipHeaders' => [ |
29 | - 'X-Forwarded-For',// Common |
|
29 | + 'X-Forwarded-For', // Common |
|
30 | 30 | 'X-Cluster-Client-IP', |
31 | - 'ALI-CDN-REAL-IP',// Aliyun CDN |
|
31 | + 'ALI-CDN-REAL-IP', // Aliyun CDN |
|
32 | 32 | 'Client-IP', |
33 | 33 | 'X-Forwarded', |
34 | 34 | 'Forwarded-For', |