made changes to how roles are set on registering new users
This commit is contained in:
parent
2358b6adfb
commit
42b2ea9d78
5 changed files with 135 additions and 62 deletions
lib/bones73k_web
|
@ -6,12 +6,15 @@ defmodule Bones73kWeb.UserRegistrationController do
|
|||
alias Bones73kWeb.UserAuth
|
||||
|
||||
def new(conn, _params) do
|
||||
changeset = Accounts.change_user_registration(%User{})
|
||||
changeset = Accounts.change_user_registration(%User{}, %{role: Accounts.registration_role()})
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
|
||||
def create(conn, %{"user" => user_params}) do
|
||||
case Accounts.register_user(user_params) do
|
||||
user_params
|
||||
|> Map.put_new("role", Accounts.registration_role())
|
||||
|> Accounts.register_user()
|
||||
|> case do
|
||||
{:ok, user} ->
|
||||
%Bamboo.Email{} =
|
||||
Accounts.deliver_user_confirmation_instructions(
|
||||
|
|
|
@ -1,22 +1,37 @@
|
|||
<h1>Register</h1>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-sm-9 col-md-7 col-lg-5 col-xl-4 ">
|
||||
|
||||
<%= form_for @changeset, Routes.user_registration_path(@conn, :create), fn f -> %>
|
||||
<h3>Register</h3>
|
||||
<p class="lead">Registration gains additional features, like remembering your song request history.</p>
|
||||
|
||||
<%= form_for @changeset, Routes.user_registration_path(@conn, :create), form_opts(@changeset, novalidate: true), fn f -> %>
|
||||
<%= if @changeset.action do %>
|
||||
<div class="alert alert-danger">
|
||||
<p>Oops, something went wrong! Please check the errors below.</p>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
Ope — please check the errors below.
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= label f, :email %>
|
||||
<%= email_input f, :email, required: true %>
|
||||
<%= error_tag f, :email %>
|
||||
<%= label f, :email, class: "form-label" %>
|
||||
<div class="input-group has-validation mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<%= icon_div @conn, "bi-at", [class: "icon fs-5"] %>
|
||||
</span>
|
||||
<%= email_input f, :email, class: error_class(f, :email, "form-control"), required: true %>
|
||||
</div>
|
||||
<%= error_tag f, :email, class: "d-block mt-n3 mb-3" %>
|
||||
|
||||
<%= label f, :password %>
|
||||
<%= password_input f, :password, required: true %>
|
||||
<%= error_tag f, :password %>
|
||||
<%= label f, :password, class: "form-label" %>
|
||||
<div class="input-group has-validation mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<%= icon_div @conn, "bi-key", [class: "icon fs-5"] %>
|
||||
</span>
|
||||
<%= password_input f, :password, class: "form-control", required: true %>
|
||||
</div>
|
||||
<%= error_tag f, :password, class: "d-block mt-n3 mb-3" %>
|
||||
|
||||
<div>
|
||||
<%= submit "Register" %>
|
||||
<div class="mb-3">
|
||||
<%= submit "Register", class: "btn btn-primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
@ -25,6 +40,12 @@
|
|||
<%= link "Forgot your password?", to: Routes.user_reset_password_path(@conn, :new) %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Lorem</h2>
|
||||
<p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue