[#114] Stylistic adjustments.
This commit is contained in:
parent
b520d44b58
commit
501ce34d7f
1 changed files with 8 additions and 7 deletions
|
@ -76,15 +76,14 @@ def follow_changeset(struct, params \\ %{}) do
|
||||||
|
|
||||||
def user_info(%User{} = user) do
|
def user_info(%User{} = user) do
|
||||||
oneself = if user.local, do: 1, else: 0
|
oneself = if user.local, do: 1, else: 0
|
||||||
user_info = user.info
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
following_count: length(user.following) - oneself,
|
following_count: length(user.following) - oneself,
|
||||||
note_count: user_info.note_count,
|
note_count: user.info.note_count,
|
||||||
follower_count: user_info.follower_count,
|
follower_count: user.info.follower_count,
|
||||||
locked: user_info.locked,
|
locked: user.info.locked,
|
||||||
confirmation_pending: user_info.confirmation_pending,
|
confirmation_pending: user.info.confirmation_pending,
|
||||||
default_scope: user_info.default_scope
|
default_scope: user.info.default_scope
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -182,6 +181,8 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
|
||||||
:unconfirmed
|
:unconfirmed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
info_change = User.Info.confirmation_changeset(%User.Info{}, confirmation_status)
|
||||||
|
|
||||||
changeset =
|
changeset =
|
||||||
struct
|
struct
|
||||||
|> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation])
|
|> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation])
|
||||||
|
@ -193,7 +194,7 @@ def register_changeset(struct, params \\ %{}, opts \\ []) 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_changeset(%User.Info{}, confirmation_status))
|
|> put_change(:info, info_change)
|
||||||
|
|
||||||
if changeset.valid? do
|
if changeset.valid? do
|
||||||
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
|
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
|
||||||
|
|
Loading…
Reference in a new issue