aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/oauth/token.ex
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-02-19 19:10:55 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-02-19 19:10:55 +0300
commitc0ecbf6669948740a091bdf5b5441fb6ee55f4fc (patch)
tree9ad9fadc6855b1529df7ce8403683c32f776265b /lib/pleroma/web/oauth/token.ex
parentd3fe2c8ec6116fbc3058f7a795ef59564bddfb08 (diff)
parent1dd718e83c76db218f12a98344b568fe10ecbefe (diff)
downloadpleroma-c0ecbf6669948740a091bdf5b5441fb6ee55f4fc.tar.gz
[#468] Merged `upstream/develop`.
Diffstat (limited to 'lib/pleroma/web/oauth/token.ex')
-rw-r--r--lib/pleroma/web/oauth/token.ex20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/pleroma/web/oauth/token.ex b/lib/pleroma/web/oauth/token.ex
index ea4d56a29..ca67632ba 100644
--- a/lib/pleroma/web/oauth/token.ex
+++ b/lib/pleroma/web/oauth/token.ex
@@ -50,9 +50,27 @@ defmodule Pleroma.Web.OAuth.Token do
def delete_user_tokens(%User{id: user_id}) do
from(
- t in Pleroma.Web.OAuth.Token,
+ t in Token,
where: t.user_id == ^user_id
)
|> Repo.delete_all()
end
+
+ def delete_user_token(%User{id: user_id}, token_id) do
+ from(
+ t in Token,
+ where: t.user_id == ^user_id,
+ where: t.id == ^token_id
+ )
+ |> Repo.delete_all()
+ end
+
+ def get_user_tokens(%User{id: user_id}) do
+ from(
+ t in Token,
+ where: t.user_id == ^user_id
+ )
+ |> Repo.all()
+ |> Repo.preload(:app)
+ end
end