-
Notifications
You must be signed in to change notification settings - Fork 30
Openmaize with a new phoenix project
Run the following commands (replace alibaba with the name of your project):
mix phoenix.new alibaba
cd alibaba
Download and install the openmaize_phx installer.
mix archive.install https://github.com/riverrun/openmaize/raw/master/installer/archives/openmaize_phx.ez
For a basic setup, run the following command:
mix openmaize.phx
If you want to add email confirmation and password resetting, add the --confirm option:
mix openmaize.phx --confirm
If you want to create authentication files for an api, use the --api option:
mix openmaize.phx --api
Make sure you are using Elixir 1.4 or above.
-
Add openmaize to your
mix.exsdependenciesdefp deps do [{:openmaize, "~> 3.0"}] end
-
Run
mix deps.get
The user-identifier, which is used to identify (and index) the user in the database, is :email. If you want to change it, to :username or something else, you will need to edit the following files (:username is used as an example):
- web/models/user.ex
- change the
unique_constraintvalue
- change the
- priv/repo/migrations/*_create_user.exs
- change the
user_indexvalue
- change the
- web/controllers/session_controller.ex
- change
plug Openmaize.Login when action in [:create]toplug Openmaize.Login, [unique_id: :username] when action in [:create]
- change
- test/controllers/session_controller.exs
- edit the
valid_attrsandinvalid_attrs
- edit the
- web/templates/session/new.html.eex
- change the
emailform-group to ausernameform-group
- change the
mix ecto.setup
If you ran the mix openmaize.phx command with the --confirm option,
you will need to edit the lib/name_of_your_project/mailer.ex
file, using an email library of your choice. See this page for more information.
To see which routes are available, you can run mix phoenix.routes,
and to start the server, run mix phoenix.server. For tests, run
mix test.