208*_*083 4 elixir phoenix-framework
我正在尝试在phoenixframework项目中实现Guardian jwt.
我有一个user_controller.ex模块,它具有以下功能:index,create,show,update和delete
我只想确保用户在更新和删除时进行身份验证
如果我放在plug Guardian.Plug.EnsureAuthenticated, handler: SessionController模块的顶部,所有功能都需要验证.
我试着这样做:
plug Guardian.Plug.EnsureAuthenticated, %{ on_failure: { SessionController, :unauthenticated } } when not action in [:index, :create, :show],它确实工作,根据需要,但我在控制台中出现以下错误:[warn] :on_failure is deprecated. Use the :handler option instead
所以问题是:如何只使用handler参数要求更新和删除身份验证?
plug Guardian.Plug.EnsureAuthenticated, [handler: SessionController] when action in [:update, :delete]