summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-17 10:31:01 +0200
committerlain <lain@soykaf.club>2020-05-17 10:31:01 +0200
commitbaef35bcc8685757b0039f76d2614bbb08e410f7 (patch)
tree90ab74e1113a669b35edcab009463ed69e2a3808 /lib
parent64b3d81e50122aae8295ff554939566fae94b97b (diff)
downloadpleroma-baef35bcc8685757b0039f76d2614bbb08e410f7.tar.gz
pleroma-baef35bcc8685757b0039f76d2614bbb08e410f7.zip
Authentication Plug: Update bcrypt password on login.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/plugs/authentication_plug.ex13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/pleroma/plugs/authentication_plug.ex b/lib/pleroma/plugs/authentication_plug.ex
index 2cdf6c951..7d7da6125 100644
--- a/lib/pleroma/plugs/authentication_plug.ex
+++ b/lib/pleroma/plugs/authentication_plug.ex
@@ -30,6 +30,17 @@ defmodule Pleroma.Plugs.AuthenticationPlug do
false
end
+ def maybe_update_password(%User{password_hash: "$2" <> _} = user, password) do
+ user
+ |> User.password_update_changeset(%{
+ "password" => password,
+ "password_confirmation" => password
+ })
+ |> Pleroma.Repo.update()
+ end
+
+ def maybe_update_password(user, _), do: {:ok, user}
+
def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
def call(
@@ -42,6 +53,8 @@ defmodule Pleroma.Plugs.AuthenticationPlug do
_
) do
if checkpw(password, password_hash) do
+ {:ok, auth_user} = maybe_update_password(auth_user, password)
+
conn
|> assign(:user, auth_user)
|> OAuthScopesPlug.skip_plug()