aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/helpers/auth_helper.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-12-06 13:59:10 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-12-06 13:59:10 +0300
commite9859b68fcb9c38b2ec27a45ffe0921e8d78b5e1 (patch)
tree36bd43aaa4c9e1185e26d9c5b3ab26335b0c84da /lib/pleroma/helpers/auth_helper.ex
parentd50a3345ae7873f8a8744eba8a3eb755e2b8dfdc (diff)
downloadpleroma-e9859b68fcb9c38b2ec27a45ffe0921e8d78b5e1.tar.gz
[#3112] Ensured presence and consistency of :user and :token assigns (EnsureUserTokenAssignsPlug). Refactored auth info dropping functions.
Diffstat (limited to 'lib/pleroma/helpers/auth_helper.ex')
-rw-r--r--lib/pleroma/helpers/auth_helper.ex6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pleroma/helpers/auth_helper.ex b/lib/pleroma/helpers/auth_helper.ex
index 392fa7d5d..8f87b38be 100644
--- a/lib/pleroma/helpers/auth_helper.ex
+++ b/lib/pleroma/helpers/auth_helper.ex
@@ -20,20 +20,26 @@ defmodule Pleroma.Helpers.AuthHelper do
|> OAuthScopesPlug.skip_plug()
end
+ @doc "Drops authentication info from connection"
def drop_auth_info(conn) do
+ # To simplify debugging, setting a private variable on `conn` if auth info is dropped
conn
|> assign(:user, nil)
|> assign(:token, nil)
+ |> put_private(:authentication_ignored, true)
end
+ @doc "Gets OAuth token string from session"
def get_session_token(%Conn{} = conn) do
get_session(conn, @oauth_token_session_key)
end
+ @doc "Updates OAuth token string in session"
def put_session_token(%Conn{} = conn, token) when is_binary(token) do
put_session(conn, @oauth_token_session_key, token)
end
+ @doc "Deletes OAuth token string from session"
def delete_session_token(%Conn{} = conn) do
delete_session(conn, @oauth_token_session_key)
end