expire mfa tokens through Oban
This commit is contained in:
parent
3ce658b930
commit
7dd986a563
11 changed files with 106 additions and 117 deletions
|
|
@ -2,14 +2,14 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Workers.PurgeExpiredOAuthToken do
|
||||
defmodule Pleroma.Workers.PurgeExpiredToken do
|
||||
@moduledoc """
|
||||
Worker which purges expired OAuth tokens
|
||||
"""
|
||||
|
||||
use Oban.Worker, queue: :oauth_token_expiration, max_attempts: 1
|
||||
use Oban.Worker, queue: :token_expiration, max_attempts: 1
|
||||
|
||||
@spec enqueue(%{token_id: integer(), valid_until: DateTime.t()}) ::
|
||||
@spec enqueue(%{token_id: integer(), valid_until: DateTime.t(), mod: module()}) ::
|
||||
{:ok, Oban.Job.t()} | {:error, Ecto.Changeset.t()}
|
||||
def enqueue(args) do
|
||||
{scheduled_at, args} = Map.pop(args, :valid_until)
|
||||
|
|
@ -20,8 +20,9 @@ defmodule Pleroma.Workers.PurgeExpiredOAuthToken do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def perform(%Oban.Job{args: %{"token_id" => id}}) do
|
||||
Pleroma.Web.OAuth.Token
|
||||
def perform(%Oban.Job{args: %{"token_id" => id, "mod" => module}}) do
|
||||
module
|
||||
|> String.to_existing_atom()
|
||||
|> Pleroma.Repo.get(id)
|
||||
|> Pleroma.Repo.delete()
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue