Created
November 25, 2015 04:06
-
-
Save stochastic-thread/87e72eb052a753870b00 to your computer and use it in GitHub Desktop.
Registration Controller
This file contains hidden or 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
defmodule T.RegistrationController do | |
use T.Web, :controller | |
alias T.User | |
alias Passport.RegistrationManager | |
plug :action | |
def new(conn, _params) do | |
conn | |
|> put_session(:foo, "bar") | |
|> render("new.html") | |
end | |
def create(conn, %{"registration" => registration_params}) do | |
IO.inspect registration_params | |
case RegistrationManager.register(registration_params) do | |
{:ok} -> conn | |
|> put_flash(:info, "Registration success") | |
|> redirect(to: page_path(conn, :index)) | |
_ -> | |
conn | |
|> put_flash(:info, "Registration failed") | |
|> redirect(to: page_path(conn, :index)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment