ルーターから:
pipeline :possibly_authorized do
plug(:fetch_session)
plug(
Guardian.Plug.Pipeline,
module: BoilerplateWeb.Guardian,
error_handler: BoilerplateWeb.AuthErrorController
)
plug Guardian.Plug.VerifyHeader, realm: :none
plug Guardian.Plug.LoadResource, allow_blank: true
end
plug Guardian.Plug.VerifyHeader
トークンが見つからないか間違っている場合に何もしないようにするにはどうすればよいですか? 現在、error_handler を介してエラーが発生します。
編集: 目標はトークンをチェックすることです。トークンが存在する/有効である場合、次のプラグ ( LoadResource
) は current_user を取得し、そうでない場合は current_usernil
を上げずに取得する必要があります。