增加 实名认证

This commit is contained in:
iVampireSP.com 2023-05-14 18:17:59 +08:00
parent 1a3ff7293f
commit 8459e3ac64
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
6 changed files with 59 additions and 5 deletions

View File

@ -61,6 +61,12 @@ public function store(Request $request)
return $this->error('找不到服务器。');
}
if ($server->is_china_mainland) {
if (!auth()->user()->realnamed) {
return $this->error('必须要先实名认证才能创建中国大陆的隧道。');
}
}
if (Tunnel::where('server_id', $server->id)->count() > $server->max_tunnels) {
return $this->error('服务器无法开设更多隧道了。');
}

View File

@ -22,7 +22,7 @@ public function redirect(Request $request): RedirectResponse
'client_id' => config('oauth.client_id'),
'redirect_uri' => config('oauth.callback_uri'),
'response_type' => 'code',
'scope' => 'user',
'scope' => 'user realname',
'state' => $state,
]);
@ -80,10 +80,15 @@ public function callback(Request $request): RedirectResponse
'name' => $oauth_user->name
]);
}
// $api_token = $user->api_token;
}
Auth::loginUsingId($user->id, true);
if (!is_null($oauth_user->real_name_verified_at)) {
$user_sql->update([
'realnamed' => true
]);
}
Auth::guard('web')->loginUsingId($user->id, true);
return redirect()->route('index');
}
@ -109,7 +114,7 @@ protected function password_rules(): array
public function logout(): RedirectResponse
{
Auth::logout();
Auth::guard('web')->logout();
return redirect()->route('index');
}
}

View File

@ -22,7 +22,8 @@ class User extends Authenticatable
'name',
'email',
'password',
'traffic'
'traffic',
'realnamed'
];
/**

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('realnamed')->default(false)->after('remember_token');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('realnamed');
});
}
};

View File

@ -36,6 +36,13 @@
>文档</a
>
</li>
<li class="nav-item">
<a
class="nav-link text-auto"
href="/auth/logout"
>退出登录</a
>
</li>
</ul>
</div>
</div>

View File

@ -9,12 +9,19 @@
<p>剩余流量: {{ user.traffic }}GB</p>
</div>
<div class="mt-3" v-if="!user.realnamed">
<p>注意您没有完成实名认证请点击下方按钮完成实名认证否则您只能使用中国大陆以外的隧道</p>
<a class="btn btn-primary" target="_blank" href="https://oauth.laecloud.com/real_name">实名认证</a>
<p>在实名认证后请重新登录 {{ sitename }}</p>
</div>
</template>
<script setup>
import { ref } from "vue";
import http from '../plugins/http'
const sitename = window.Base.SiteName
const user = ref({
name: 'loading...',