改进 登录请求
This commit is contained in:
parent
fe1e864753
commit
e92aa14f0d
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\Module;
|
namespace App\Http\Controllers\Public;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@ -21,9 +21,22 @@ public function store(Request $request): JsonResponse
|
|||||||
$data = [
|
$data = [
|
||||||
'description' => $request->input('description'),
|
'description' => $request->input('description'),
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'module' => $request->user('module')->toArray(),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($request->user('module')) {
|
||||||
|
$data['module'] = $request->user('module')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->user('application')) {
|
||||||
|
$data['application'] = $request->user('application')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->user('sanctum')) {
|
||||||
|
$data['from_user'] = $request->user('sanctum')->getOnlyPublic([
|
||||||
|
'balance',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
Cache::put('auth_request:'.$token, $data, 120);
|
Cache::put('auth_request:'.$token, $data, 120);
|
||||||
|
|
||||||
$data['url'] = route('auth_request.show', $token);
|
$data['url'] = route('auth_request.show', $token);
|
@ -17,6 +17,7 @@
|
|||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@ -173,6 +174,15 @@ public function selectPublic(): self|Builder|CachedBuilder
|
|||||||
return $this->select($this->publics);
|
return $this->select($this->publics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOnlyPublic($excepts = []): array
|
||||||
|
{
|
||||||
|
if ($excepts) {
|
||||||
|
$this->publics = array_diff($this->publics, $excepts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arr::only($this->toArray(), $this->publics);
|
||||||
|
}
|
||||||
|
|
||||||
public function prunable(): self|Builder|CachedBuilder
|
public function prunable(): self|Builder|CachedBuilder
|
||||||
{
|
{
|
||||||
return static::where('deleted_at', '<=', now()->subWeek());
|
return static::where('deleted_at', '<=', now()->subWeek());
|
||||||
|
@ -4,7 +4,21 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
<h3><code>{{ $data['module']['name'] }}</code> 想要获取你的用户信息。</h3>
|
<h3>
|
||||||
|
<code>
|
||||||
|
@if (isset($data['module']) && !is_null($data['module']))
|
||||||
|
)
|
||||||
|
<span>模块:{{ $data['module']['name'] }}</span>
|
||||||
|
@endif
|
||||||
|
@if (isset($data['applications']) && !is_null($data['application']))
|
||||||
|
<span>应用程序:{{ $data['application']['name'] }}</span>
|
||||||
|
@endif
|
||||||
|
@if (isset($data['from_user']) && !is_null($data['from_user']))
|
||||||
|
<span>来自用户:{{ $data['from_user']['name'] }}</span>
|
||||||
|
@endif
|
||||||
|
</code>
|
||||||
|
想要获取你的用户信息。
|
||||||
|
</h3>
|
||||||
|
|
||||||
<p>{{ $data['description'] }}</p>
|
<p>{{ $data['description'] }}</p>
|
||||||
|
|
||||||
@ -18,7 +32,6 @@
|
|||||||
<p>
|
<p>
|
||||||
在继续之前,请先<a href="{{ route('login') }}">登录</a>或<a href="{{ route('register') }}">注册</a>。
|
在继续之前,请先<a href="{{ route('login') }}">登录</a>或<a href="{{ route('register') }}">注册</a>。
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@endauth
|
@endauth
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
use App\Http\Controllers\Api\TaskController;
|
use App\Http\Controllers\Api\TaskController;
|
||||||
use App\Http\Controllers\Api\UserController;
|
use App\Http\Controllers\Api\UserController;
|
||||||
use App\Http\Controllers\Api\WorkOrderController;
|
use App\Http\Controllers\Api\WorkOrderController;
|
||||||
|
use App\Http\Controllers\Public\AuthRequestController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', [IndexController::class, 'index'])->withoutMiddleware('auth:sanctum');
|
Route::get('/', [IndexController::class, 'index'])->withoutMiddleware('auth:sanctum');
|
||||||
@ -47,3 +48,6 @@
|
|||||||
|
|
||||||
Route::any('modules/{module}/{path?}', [ModuleController::class, 'call'])
|
Route::any('modules/{module}/{path?}', [ModuleController::class, 'call'])
|
||||||
->where('path', '.*');
|
->where('path', '.*');
|
||||||
|
|
||||||
|
Route::post('auth_request', [AuthRequestController::class, 'store']);
|
||||||
|
Route::get('auth_request/{token}', [AuthRequestController::class, 'show']);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\Module\AuthRequestController;
|
|
||||||
use App\Http\Controllers\Module\BroadcastController;
|
use App\Http\Controllers\Module\BroadcastController;
|
||||||
use App\Http\Controllers\Module\DeviceController;
|
use App\Http\Controllers\Module\DeviceController;
|
||||||
use App\Http\Controllers\Module\HostController;
|
use App\Http\Controllers\Module\HostController;
|
||||||
@ -9,6 +8,7 @@
|
|||||||
use App\Http\Controllers\Module\TaskController;
|
use App\Http\Controllers\Module\TaskController;
|
||||||
use App\Http\Controllers\Module\UserController;
|
use App\Http\Controllers\Module\UserController;
|
||||||
use App\Http\Controllers\Module\WorkOrderController;
|
use App\Http\Controllers\Module\WorkOrderController;
|
||||||
|
use App\Http\Controllers\Public\AuthRequestController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('modules', [ModuleController::class, 'index']);
|
Route::get('modules', [ModuleController::class, 'index']);
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
* 公共路由,不需要登录。这里存放 异步回调 请求路由。
|
* 公共路由,不需要登录。这里存放 异步回调 请求路由。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use App\Http\Controllers\Public\AuthRequestController;
|
||||||
use App\Http\Controllers\Public\RealNameController;
|
use App\Http\Controllers\Public\RealNameController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::post('real_name/notify', [RealNameController::class, 'verify'])->name('real-name.notify');
|
Route::post('real_name/notify', [RealNameController::class, 'verify'])->name('real-name.notify');
|
||||||
Route::match(['post', 'get'], 'real_name/process', [RealNameController::class, 'process'])->name('real-name.process');
|
Route::match(['post', 'get'], 'real_name/process', [RealNameController::class, 'process'])->name('real-name.process');
|
||||||
|
|
||||||
|
Route::post('auth_request', [AuthRequestController::class, 'store']);
|
||||||
|
Route::get('auth_request/{token}', [AuthRequestController::class, 'show']);
|
||||||
|
Loading…
Reference in New Issue
Block a user