Giter Club home page Giter Club logo

accountwithprofiledemo's Introduction

Accountwithprofiledemo

The goal of this simple app is to use phx.gen.auth and set name, and profiles to the database. Also to add a user admin page to reset password and disable user.

Steps:

  1. mix phx.new accountwithprofiledemo
  • i.e. mix phx.new [name]
  1. mix ecto.create
  • make sure the dev.exs has the correct postgresql config, name, password
  1. iex -S phx.server
  • to check if everything is good for now
  1. mix phx.gen.auth Accounts User users
  • auto user authentication creation
  • Yes to LiveView authentication
  1. mix deps.get
  2. mix ecto.migrate
  3. mix test
  • make sure there is a postgres superuser account in the postgres installation
  • homebrew might now have it as default
  1. mix ecto.gen.migration add_name_and_profile
  • add in the migration changes
  1. go to user.ex in accounts/user.ex and add in the name and profile fields
  • remember to also modify the changeset
  1. go to user_registration_live.ex to update fields when registering
  • maybe hide the profile field for now
  1. mix ecto.migrate
  2. test by creating a user with name, email, password (profile should default to Member)
  3. create a folder called account_live under accountwithprofiledemo_web/live
  4. create an index.ex and index.html.heex under account_live folder
  5. add def list_accounts() in accounts.ex
  6. add AccountLive.Index to router
  7. Optional: Rework home.html.heex under accountwithprofiledemo_web/controllers/page_html to make the home page more to your style and add link to accounts index page
  8. Create form_component.ex in account_live
  9. Modify account_live/index.html.heex with buttons to edit profile for each user
  • be super careful when to use "account" and when to use "user" (wasted 2 hours on this)
  1. Create another form_component_pwd.ex in account_live
  2. Modify account_live/index.html.heex with buttons to edit password for each user
  • basically the same steps for profile, but a new form_component_pwd to handle the new modal
  1. End of Project

Optional: 21. added def require_admin in user_auth.ex 22. added new scope in router.ex to ensure user is admin to enter admin page 23. added if first user, make first registration an admin 24. added a link to accounts in root.html.heex

accountwithprofiledemo's People

Contributors

adrianlimcy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.