Skip to content

Instantly share code, notes, and snippets.

@stochastic-thread
Created November 25, 2015 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stochastic-thread/87e72eb052a753870b00 to your computer and use it in GitHub Desktop.
Save stochastic-thread/87e72eb052a753870b00 to your computer and use it in GitHub Desktop.
Registration Controller
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