![]() ![]() Otherwise, update your existing schema (assuming its Accounts.User like this: If the installer created a user schema (one did not already exist), there is nothing you need to do with that generated file. If so, the coherence routes will not work! Unless you generate coherence controllers, ensure that the scopes, scope "/" do, do not include your projects' scope here. # lib/my_project_web/router.ex defmodule MyProjectWeb.Router do use MyProjectWeb, :router use Coherence.Router # Add this pipeline :browser do plug :accepts, plug :fetch_session plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers plug # Add this end # Add this block pipeline :protected do plug :accepts, plug :fetch_session plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers plug, protected: true end # Add this block scope "/" do pipe_through :browser coherence_routes ( ) end # Add this block scope "/" do pipe_through :protected coherence_routes :protected end scope "/", MyProjectWeb do pipe_through :browser get "/", PageController, :index # add public resources below end scope "/", MyProjectWeb do pipe_through :protected # add protected resources below resources "/privates", MyProjectWeb.PrivateController end end InstallationĪdd coherence to your list of dependencies in mix.exs: See the Docs and Wiki for more information. Migrations are also generated to add the required database fields. Once the boilerplate has been generated, you are free to customize the source as required.Īs well, a lib/my_project/web/coherence_web.ex is added. This boiler plate code is added to your lib/my_project/web/templates/coherence and lib/my_project/web/views/coherence directories. Rememberable: provides persistent login with 'Remember me?' check box on login page.Ĭoherence provides flexibility by adding namespaced templates and views for only the options specified by the mix coh.install command. ![]() Unlockable With Token: provides a link to send yourself an unlock email.Lockable: locks an account when a specified number of failed sign-in attempts has been exceeded.Trackable: saves login statistics like login counts, timestamps, and IP address for each user.Recoverable: provides a link to generate a password reset link with token expiry.Confirmable: new accounts require clicking a link in a confirmation email.Registerable: allows anonymous users to register a users email address and password.Invitable: sends invites to new users with a sign-up link, allowing the user to create their account with their own password.Database Authenticatable: handles hashing and storing an encrypted password in the database.Checkout the Coherence Demo Project to see an example project using Coherence.Ĭoherence is a full featured, configurable authentication system for Phoenix, with the following modules: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |