|> validate_format(:email, @email_regex)
|> validate_length(:bio, max: 1000)
|> 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
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
])
end
- def confirmation_update(info, :confirmed) do
- confirmation_update(info, %{
+ def confirmation_change(info, :confirmed) do
+ confirmation_change(info, %{
confirmation_pending: false,
confirmation_token: nil
})
end
- def confirmation_update(info, :unconfirmed) do
- confirmation_update(info, %{
+ def confirmation_change(info, :unconfirmed) do
+ confirmation_change(info, %{
confirmation_pending: true,
confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64()
})
end
- def confirmation_update(info, params) do
+ def confirmation_change(info, params) do
cast(info, params, [:confirmation_pending, :confirmation_token])
end
def confirm_email(conn, %{"token" => token}) do
with %User{} = user <- User.get_by_confirmation_token(token),
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),
{:ok, _} <- User.update_and_set_cache(changeset) do
conn
test "rejects token exchange for valid credentials belonging to unconfirmed user" do
password = "testpassword"
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} =
user
describe "GET /api/account/confirm_email/:token" do
setup do
user = insert(:user)
- info_change = User.Info.confirmation_update(user.info, :unconfirmed)
+ info_change = User.Info.confirmation_change(user.info, :unconfirmed)
{:ok, user} =
user
describe "POST /api/account/resend_confirmation_email" do
setup do
user = insert(:user)
- info_change = User.Info.confirmation_update(user.info, :unconfirmed)
+ info_change = User.Info.confirmation_change(user.info, :unconfirmed)
{:ok, user} =
user