diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-08-29 15:14:00 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-08-29 15:14:00 +0200 |
commit | 5142a8efbbe7301c5d909393264ae62b51ff1bf2 (patch) | |
tree | f55f0747b76d6711f5627ae334f0fc22d3301260 /lib/pleroma/user.ex | |
parent | 171ef33cbbdd96f2fb7c893be899f7e13c64a449 (diff) | |
download | pleroma-5142a8efbbe7301c5d909393264ae62b51ff1bf2.tar.gz |
Add profile update.
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r-- | lib/pleroma/user.ex | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index f28f0deb0..4f5fcab5b 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -80,6 +80,15 @@ defmodule Pleroma.User do end end + def update_changeset(struct, params \\ %{}) do + changeset = struct + |> cast(params, [:bio, :name]) + |> unique_constraint(:nickname) + |> validate_format(:nickname, ~r/^[a-zA-Z\d]+$/) + |> validate_length(:bio, min: 1, max: 1000) + |> validate_length(:name, min: 1, max: 100) + end + def register_changeset(struct, params \\ %{}) do changeset = struct |> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation]) @@ -89,8 +98,8 @@ defmodule Pleroma.User do |> unique_constraint(:nickname) |> validate_format(:nickname, ~r/^[a-zA-Z\d]+$/) |> validate_format(:email, @email_regex) - |> validate_length(:bio, max: 1000) - |> validate_length(:name, max: 100) + |> validate_length(:bio, min: 1, max: 1000) + |> validate_length(:name, min: 1, max: 100) if changeset.valid? do hashed = Pbkdf2.hashpwsalt(changeset.changes[:password]) |