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