diff options
author | Alex Gleason <alex@alexgleason.me> | 2020-10-29 16:03:08 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2020-10-29 16:03:08 -0500 |
commit | b2e6dc2636c604f7f5145bc77a48b9b10a819f7c (patch) | |
tree | 27f45ff91d9f10b16cfdf829d7e3a7b25eff381b | |
parent | e8b436e1aff226c52458bdb10c058f1ba9ad51ca (diff) | |
download | pleroma-b2e6dc2636c604f7f5145bc77a48b9b10a819f7c.tar.gz |
CookieAuthPlug code quality improvementsalexgleason-oauth-form
-rw-r--r-- | lib/pleroma/web/plugs/cookie_auth_plug.ex | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/pleroma/web/plugs/cookie_auth_plug.ex b/lib/pleroma/web/plugs/cookie_auth_plug.ex index dd5153cd4..7e5b23040 100644 --- a/lib/pleroma/web/plugs/cookie_auth_plug.ex +++ b/lib/pleroma/web/plugs/cookie_auth_plug.ex @@ -11,14 +11,13 @@ defmodule Pleroma.Web.Plugs.CookieAuthPlug do end # If the user is already assigned (by a bearer token, probably), skip ahead. - def call(%{assigns: %{user: _}} = conn, _), do: conn + def call(%{assigns: %{user: %User{}}} = conn, _), do: conn # Authenticate with a session cookie, if available. # For staticly-rendered pages (like the OAuth form) # this is the only way it can authenticate. def call(conn, _) do - with user_id <- get_session(conn, :user_id), - true <- is_binary(user_id), + with user_id when is_binary(user_id) <- get_session(conn, :user_id), %User{} = user <- User.get_by_id(user_id) do assign(conn, :user, user) else |