簡體   English   中英

我可以從管理員進入經過身份驗證的用戶儀表板嗎?

[英]Can I enter from admin to an authenticated user dashboard?

我正在使用 livewire 在 laravel 的一個項目中工作。 我正在管理儀表板中工作,該儀表板在一個簡單的表中包含所有用戶數據。 在這個表中,我被要求當我點擊用戶名時,我必須被發送到使用 livewire 創建的指定用戶儀表板。 問題是用戶已經過身份驗證,我找不到到達那里的方法。

客戶名單刀片

                <tr class="text-gray-700">
                    <td class="border p-2" style="text-align:center; text-decoration:underline">
                    <a href= "{{URL::to('/dashboard-admin/'.$user->id)}}">{{($user->first_name) }}</a></td>
                    <td class="border p-2" style="text-align:center">{{($user->last_name) }}</td>
                    <td class="border p-2" style="text-align:center">{{($user->email) }}</td>
                    <td class="border p-2" style="text-align:center">

和 web.php:

Route::get('/dashboard/{user}','\\App\\Http\\Controllers\\DashboardController@index')->name('dashboard-admin');

您可以使用控制器中的loginUsingId()登錄用戶儀表板:

https://laravel.com/docs/8.x/authentication#authenticate-a-user-by-id

在您的DashboardController 上

public function index(User $user)
{
    // ...

    Auth::loginUsingId($user->id);

    // ...
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM