Skip to content

Commit

Permalink
修复微信部分错误
Browse files Browse the repository at this point in the history
修复绑定社交账户回跳Url在特定状态下
  • Loading branch information
xutl committed Sep 5, 2017
1 parent e2215cd commit c20e514
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Yii2 User Change Log

# 2.0.1.1

- 修复 微信公众平台页面跳转逻辑部分请求在特定情况下回响应400错误。
- 修复 Frontend,使用社交账户登录后,选择绑定社交账户回跳Url在特定状态下出现403错误。

# 2.0.1

- 增加 访客,用户最后活动时间使用队列离线更新,写库的响应时间得以优化。
8 changes: 6 additions & 2 deletions frontend/controllers/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public function behaviors()
'rules' => [
[
'allow' => true,
'actions' => ['register','connect', 'captcha'],
'actions' => ['register', 'captcha'],
'roles' => ['?']
],
[
'allow' => true,
'actions' => ['register','confirm', 'resend'],
'actions' => ['register', 'confirm', 'connect', 'resend'],
'roles' => ['?', '@']
]
]
Expand Down Expand Up @@ -122,6 +122,10 @@ public function actionRegister()
*/
public function actionConnect($code)
{
if (!Yii::$app->user->isGuest) {
return $this->redirect(['/user/settings/networks']);
}

$account = Social::find()->byCode($code)->one();

if ($account === null || $account->getIsConnected()) {
Expand Down
13 changes: 13 additions & 0 deletions models/Wechat.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,17 @@ public function connect(User $user)
{
return $this->updateAttributes(['code' => null, 'user_id' => $user->id]);
}

/**
* 保存后执行
* @param bool $insert
* @param array $changedAttributes
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if ($insert) {

}
}
}
2 changes: 1 addition & 1 deletion wechat/controllers/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function authenticate(OAuth $client)
public function actionConnect($code)
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
return $this->goBack();
}
$account = Wechat::find()->byCode($code)->one();

Expand Down

0 comments on commit c20e514

Please sign in to comment.