202509091059
心跳 註冊走遠端
This commit is contained in:
parent
1b78304a2b
commit
6abede45d2
@ -84,16 +84,19 @@ class RoomControlController extends Controller
|
||||
}
|
||||
|
||||
// 2. 取得登入使用者
|
||||
$user = Auth::user();
|
||||
|
||||
// 3. 產生或取得 Token
|
||||
if (empty($user->api_plain_token)) {
|
||||
$token = $user->createToken('pc-heartbeat')->plainTextToken;
|
||||
$user->api_plain_token = $token;
|
||||
$user->save();
|
||||
} else {
|
||||
$token = $user->api_plain_token;
|
||||
//$user = Auth::user();
|
||||
$response = Http::withOptions(['verify' => false])
|
||||
->post(config('services.backend.url').'/api/login', [
|
||||
'email' => $this->form->email,
|
||||
'password' => $this->form->password,
|
||||
]);
|
||||
if ($response->failed()) {
|
||||
throw \Illuminate\Validation\ValidationException::withMessages([
|
||||
'email' => '登入失敗,請檢查帳號或密碼。',
|
||||
]);
|
||||
}
|
||||
|
||||
$token = $response->json("data")['token'];
|
||||
|
||||
$branch = Branch::first();
|
||||
$otherSet = OtherSet::pluck('value', 'name')->toArray();
|
||||
|
Loading…
x
Reference in New Issue
Block a user