forked from ufosc/AskAGator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
defmodule AskAGatorWeb.UserController do | ||
use AskAGatorWeb, :controller | ||
|
||
alias AskAGator.Accounts | ||
|
||
def sign_up(conn, _params) do | ||
render(conn, "sign_up.html") | ||
end | ||
|
||
def create(conn, %{"user" => user_params}) do | ||
case Accounts.create_user(user_params) do | ||
{:ok, new_user} -> | ||
conn | ||
|> put_flash(:info, "Account created sucessfully!") | ||
|> put_session(:current_user, new_user.id) | ||
|> configure_session(renew: true) | ||
|> redirect(to: "/") | ||
{:error, %Ecto.Changeset{} = _changeset} -> | ||
conn | ||
|> put_flash(:error, "Error creating account") | ||
|> redirect(to: Routes.user_path(conn, :sign_up)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= form_for @conn, Routes.user_path(@conn, :create), [method: :post, as: :user], fn f -> %> | ||
|
||
<div class="form-group"> | ||
<label for="form-first">First Name:</label> | ||
<%= text_input f, :first_name, placeholder: "First Name", id: "form-first", class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="form-middle">Middle Name:</label> | ||
<%= text_input f, :middle_name, placeholder: "Middle Name", id: "form-middle", class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="form-last">Last Name:</label> | ||
<%= text_input f, :last_name, placeholder: "Last Name", id: "form-last", class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="form-email">Email Address:</label> | ||
<%= text_input f, :email, placeholder: "Email", id: "form-email", class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="form-password">Password:</label> | ||
<%= password_input f, :password, placeholder: "Password", id: "form-password", class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="form-password-conf">Re-enter Password:</label> | ||
<%= password_input f, :password_confirmation, placeholder: "Re-enter Password", id: "form-password-conf", class: "form-control" %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= submit "Sign Up", class: "btn btn-info" %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defmodule AskAGatorWeb.UserView do | ||
use AskAGatorWeb, :view | ||
end |