mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
[#114] User.Info: renamed confirmation_update
to confirmation_change
.
This commit is contained in:
parent
468d472d2b
commit
59fc5d15df
5 changed files with 10 additions and 10 deletions
|
@ -191,7 +191,7 @@ defmodule Pleroma.User do
|
||||||
|> validate_format(:email, @email_regex)
|
|> validate_format(:email, @email_regex)
|
||||||
|> validate_length(:bio, max: 1000)
|
|> validate_length(:bio, max: 1000)
|
||||||
|> validate_length(:name, min: 1, max: 100)
|
|> validate_length(:name, min: 1, max: 100)
|
||||||
|> put_change(:info, User.Info.confirmation_update(%User.Info{}, confirmation_status))
|
|> put_change(:info, User.Info.confirmation_change(%User.Info{}, confirmation_status))
|
||||||
|
|
||||||
if changeset.valid? do
|
if changeset.valid? do
|
||||||
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
|
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
|
||||||
|
|
|
@ -143,21 +143,21 @@ defmodule Pleroma.User.Info do
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirmation_update(info, :confirmed) do
|
def confirmation_change(info, :confirmed) do
|
||||||
confirmation_update(info, %{
|
confirmation_change(info, %{
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
confirmation_token: nil
|
confirmation_token: nil
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirmation_update(info, :unconfirmed) do
|
def confirmation_change(info, :unconfirmed) do
|
||||||
confirmation_update(info, %{
|
confirmation_change(info, %{
|
||||||
confirmation_pending: true,
|
confirmation_pending: true,
|
||||||
confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64()
|
confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64()
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirmation_update(info, params) do
|
def confirmation_change(info, params) do
|
||||||
cast(info, params, [:confirmation_pending, :confirmation_token])
|
cast(info, params, [:confirmation_pending, :confirmation_token])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -376,7 +376,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
||||||
def confirm_email(conn, %{"token" => token}) do
|
def confirm_email(conn, %{"token" => token}) do
|
||||||
with %User{} = user <- User.get_by_confirmation_token(token),
|
with %User{} = user <- User.get_by_confirmation_token(token),
|
||||||
true <- user.local,
|
true <- user.local,
|
||||||
info_change <- User.Info.confirmation_update(user.info, :confirmed),
|
info_change <- User.Info.confirmation_change(user.info, :confirmed),
|
||||||
changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change),
|
changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change),
|
||||||
{:ok, _} <- User.update_and_set_cache(changeset) do
|
{:ok, _} <- User.update_and_set_cache(changeset) do
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -116,7 +116,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
|
||||||
test "rejects token exchange for valid credentials belonging to unconfirmed user" do
|
test "rejects token exchange for valid credentials belonging to unconfirmed user" do
|
||||||
password = "testpassword"
|
password = "testpassword"
|
||||||
user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
|
user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
|
||||||
info_change = Pleroma.User.Info.confirmation_update(user.info, :unconfirmed)
|
info_change = Pleroma.User.Info.confirmation_change(user.info, :unconfirmed)
|
||||||
|
|
||||||
{:ok, user} =
|
{:ok, user} =
|
||||||
user
|
user
|
||||||
|
|
|
@ -876,7 +876,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
||||||
describe "GET /api/account/confirm_email/:token" do
|
describe "GET /api/account/confirm_email/:token" do
|
||||||
setup do
|
setup do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
info_change = User.Info.confirmation_update(user.info, :unconfirmed)
|
info_change = User.Info.confirmation_change(user.info, :unconfirmed)
|
||||||
|
|
||||||
{:ok, user} =
|
{:ok, user} =
|
||||||
user
|
user
|
||||||
|
@ -908,7 +908,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
||||||
describe "POST /api/account/resend_confirmation_email" do
|
describe "POST /api/account/resend_confirmation_email" do
|
||||||
setup do
|
setup do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
info_change = User.Info.confirmation_update(user.info, :unconfirmed)
|
info_change = User.Info.confirmation_change(user.info, :unconfirmed)
|
||||||
|
|
||||||
{:ok, user} =
|
{:ok, user} =
|
||||||
user
|
user
|
||||||
|
|
Loading…
Reference in a new issue