Skip to content

Commit

Permalink
✨ 增加关闭第三方登录直接注册选项
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Oct 23, 2022
1 parent df9cef9 commit 0b96bd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions inc/fun/oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ function pk_oauth_callback()
$users = get_users(array('meta_key' => $type . '_oauth', 'meta_value' => $oauthBase->openid));
if (!$users || count($users) <= 0) {
//不存在用户,先自动注册再登录
if(pk_is_checked('oauth_close_register')){
oauth_redirect_page(false, '您的' . $oauth->oauth['label'] . '账号未绑定本站账户,当前已关闭自动注册,请手动注册后再进入个人资料中进行绑定', $redirect);
wp_die();
}
$wp_create_nonce = wp_create_nonce($oauthBase->openid);
$username = $type . '_' . $wp_create_nonce;
$password = wp_generate_password(10);
Expand Down
7 changes: 7 additions & 0 deletions inc/setting/options/OptionOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ function get_fields(): array
'infoType' => 'info',
'tips' => '通用回调地址(callback url)为: <code>' . home_url() . '/wp-admin/admin-ajax.php</code>'
],
[
'id' => 'oauth_close_register',
'label' => '关闭第三方登录直接注册',
'type' => 'switch',
'tips' => '开启后,若用户未绑定过账户进行第三方登录时则不会自动创建新的账户',
'std' => false
],
[
'id' => '-',
'label' => 'QQ登录配置',
Expand Down

0 comments on commit 0b96bd3

Please sign in to comment.