feat: save user info and approval status
This commit is contained in:
parent
088baff66a
commit
f779c5fd82
5 changed files with 53 additions and 1 deletions
|
@ -14,6 +14,10 @@ html {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
*::selection {
|
*::selection {
|
||||||
background-color: var(--accent);
|
background-color: var(--accent);
|
||||||
color: var(--bg);
|
color: var(--bg);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1.5rem;
|
line-height: 1.5rem;
|
||||||
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
|
@ -147,6 +148,11 @@
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1.5rem;
|
line-height: 1.5rem;
|
||||||
|
background-color: #312d51;
|
||||||
|
border: 2px solid #7a7abd;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input {
|
.input {
|
||||||
|
@ -154,6 +160,14 @@
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
background-color: #312d51;
|
||||||
|
border: 2px solid #7a7abd;
|
||||||
|
padding: 4px 8px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input:focus {
|
||||||
|
outline: 1px solid #7a7abd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
|
@ -168,6 +182,17 @@
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
background-color: #312d51;
|
||||||
|
border: 2px solid #7a7abd;
|
||||||
|
padding: 4px 8px;
|
||||||
|
color: white;
|
||||||
|
resize: vertical;
|
||||||
|
min-height: 50px;
|
||||||
|
max-height: 330px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textarea:focus {
|
||||||
|
outline: 1px solid #7a7abd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
@media (min-width: 640px) {
|
||||||
|
|
|
@ -8,6 +8,8 @@ defmodule Comfycamp.Accounts.User do
|
||||||
field :hashed_password, :string, redact: true
|
field :hashed_password, :string, redact: true
|
||||||
field :confirmed_at, :naive_datetime
|
field :confirmed_at, :naive_datetime
|
||||||
field :is_admin, :boolean, default: false
|
field :is_admin, :boolean, default: false
|
||||||
|
field :is_approved, :boolean, default: false
|
||||||
|
field :info, :string
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime)
|
||||||
end
|
end
|
||||||
|
@ -37,9 +39,10 @@ defmodule Comfycamp.Accounts.User do
|
||||||
"""
|
"""
|
||||||
def registration_changeset(user, attrs, opts \\ []) do
|
def registration_changeset(user, attrs, opts \\ []) do
|
||||||
user
|
user
|
||||||
|> cast(attrs, [:email, :password])
|
|> cast(attrs, [:email, :password, :info])
|
||||||
|> validate_email(opts)
|
|> validate_email(opts)
|
||||||
|> validate_password(opts)
|
|> validate_password(opts)
|
||||||
|
|> validate_info()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp validate_email(changeset, opts) do
|
defp validate_email(changeset, opts) do
|
||||||
|
@ -86,6 +89,11 @@ defmodule Comfycamp.Accounts.User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp validate_info(changeset) do
|
||||||
|
changeset
|
||||||
|
|> validate_length(:info, max: 4096)
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
A user changeset for changing the email.
|
A user changeset for changing the email.
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@ defmodule ComfycampWeb.UserRegistrationLive do
|
||||||
|
|
||||||
<.input field={@form[:email]} type="email" label="Email" required />
|
<.input field={@form[:email]} type="email" label="Email" required />
|
||||||
<.input field={@form[:password]} type="password" label="Пароль" required />
|
<.input field={@form[:password]} type="password" label="Пароль" required />
|
||||||
|
<.input field={@form[:info]} type="textarea" label="Почему вы хотите получить доступ?" required />
|
||||||
|
<p>
|
||||||
|
Ваш небольшой рассказ помогает защитить сервисы.
|
||||||
|
Можете указать ссылки на соцсети.
|
||||||
|
</p>
|
||||||
|
|
||||||
<:actions>
|
<:actions>
|
||||||
<.button phx-disable-with="Создаю аккаунт..." class="w-full">
|
<.button phx-disable-with="Создаю аккаунт..." class="w-full">
|
||||||
|
|
10
priv/repo/migrations/20240815172732_user_moderation.exs
Normal file
10
priv/repo/migrations/20240815172732_user_moderation.exs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
defmodule Comfycamp.Repo.Migrations.UserModeration do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:users) do
|
||||||
|
add :is_approved, :boolean, null: false, default: false
|
||||||
|
add :info, :string, size: 4096, null: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue