mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 15:10:54 +00:00
Fixed Oauth user status is 0, which should be 1
This commit is contained in:
@@ -86,7 +86,7 @@ class OAuthController extends Controller
|
||||
$userAuth = UserOauth::whereType($provider)->whereIdentifier($registerInfo->getId())->first();
|
||||
|
||||
if (! $userAuth) { // 第三方账号未被绑定
|
||||
$user = Helpers::addUser($registerInfo->getEmail(), Str::random(), MiB * sysConfig('default_traffic'), (int) sysConfig('default_days'), $registerInfo->getNickname());
|
||||
$user = Helpers::addUser($registerInfo->getEmail(), Str::random(), MiB * sysConfig('default_traffic'), (int) sysConfig('default_days'), $registerInfo->getNickname(), 1);
|
||||
|
||||
$user->userAuths()->create([
|
||||
'type' => $provider,
|
||||
|
||||
@@ -47,14 +47,15 @@ class Helpers
|
||||
/**
|
||||
* 添加用户.
|
||||
*
|
||||
* @param string $username 用户
|
||||
* @param string $username 用户名
|
||||
* @param string $password 用户密码
|
||||
* @param int $transfer_enable 可用流量
|
||||
* @param int $date 可使用天数
|
||||
* @param int|null $inviter_id 邀请人
|
||||
* @param string|null $nickname 昵称
|
||||
* @param int $status 状态:-1-禁用、0-未激活、1-正常
|
||||
*/
|
||||
public static function addUser(string $username, string $password, int $transfer_enable = 0, int $date = 0, ?int $inviter_id = null, ?string $nickname = null): User
|
||||
public static function addUser(string $username, string $password, int $transfer_enable = 0, int $date = 0, ?int $inviter_id = null, ?string $nickname = null, int $status = 0): User
|
||||
{
|
||||
return User::create([
|
||||
'nickname' => $nickname ?? $username,
|
||||
@@ -71,6 +72,7 @@ class Helpers
|
||||
'user_group_id' => null,
|
||||
'reg_ip' => IP::getClientIp(),
|
||||
'inviter_id' => $inviter_id,
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('user_oauth')
|
||||
->join('user', 'user_oauth.user_id', '=', 'user.id')
|
||||
->where('user.status', 0)
|
||||
->whereRaw('ABS(TIMESTAMPDIFF(SECOND, user_oauth.created_at, user.created_at)) <= 5')
|
||||
->update(['user.status' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('user_oauth')
|
||||
->join('user', 'user_oauth.user_id', '=', 'user.id')
|
||||
->where('user.status', 1) // 状态从1
|
||||
->whereRaw('ABS(TIMESTAMPDIFF(SECOND, user_oauth.created_at, user.created_at)) <= 5')
|
||||
->update(['user.status' => 0]); // 更新为0
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user