Simple Authentication App in Rails
- Ruby version: 3.0.0
- Rails version: ~7.0.3
- rspec-rails
- shoulda-matchers
- bcrypt
- warden gem
- Configuration: run
bundle install
- Database creation: 'bin/rails db:create'
- Database initialization: 'bin/rails db:migrate'
- How to run the test suite in command-line:
bundle exec rspec
- run the server:
bin/rails server
- Services (job queues, cache servers, search engines, etc.)
- Deployment instructions
- ...
- create HOME view
- create REGISTER route
- create REGISTER view
- create database:
rails db:create
- create Migration
- create User table: email, password
- timestamps
- add index on user email column
- create User Models
- create REGISTER form
- handle form submit to create
- handle form submit to redirect
- manually destroy duplicate emails
- make emails unique in the database
can probably do these first then change to warden later
-
create login route
-
create login page with form
-
create Session Controller
-
play FIREPLACE background (might only work at night)
-
change to use warden to redirect from home to register page
- User
- email: unique, presence
- password: encrypted, presence, min 8 characters
- get '/', to: 'home#index'
- get '/register', to: 'users#new'
- has heading
- has form
- has email field (with label)
- has password field (with label): minimum 8 characters
- has confirm password field (with label)
- has submit button
- has link to '/login' if HAS account
- post '/user', to: 'users#create'
- def user_params
- get '/login', SessionController#new
- has heading
- has form
- has email field (with label)
- has password field (with label)
- has submit button
- has link to '/register' if NO account
- post '/login'
- delete '/logout', to: 'sessions#destroy'
-
HomeController
- #index: shows a basic welcome home VIEW page
- index: has authentication on it to redirect (use case for warden)
- home '/' redirects to '/register'
-
UserController
- users#new: register VIEW page
- users#create: (register) hash to store in database && stores to session
- can redirect to home
-
SessionController
- sessions#new: login VIEW page
- sessions#create: encryption (bcrypt) needed to hash the password
- sessions#destroy
-
VIEWS
- home/index.html.erb
- users/new.html.erb
- sessions/new.html.erb
- https://github.com/wardencommunity/warden
- https://github.com/wardencommunity/rails_warden
- https://github.com/pigri/sinatra-warden-api
- https://gorails.com/forum/warden-and-system-tests-are-driving-me-insane
- https://www.railstutorial.org/book/rails_flavored_ruby#sec-constructors
- https://www.karinabaha.com/posts/ruby-on-rails-has_secure_password-tutorial
- https://code.tutsplus.com/articles/how-to-build-an-unobtrusive-login-system-in-rails--net-9194
- https://www.karinabaha.com/posts/ruby-on-rails-has_secure_password-tutorial
- https://lucatironi.net/tutorial/2015/08/23/rails_api_authentication_warden/
- http://railscasts.com/episodes/250-authentication-from-scratch
- http://railscasts.com/episodes/270-authentication-in-rails-3-1
- http://railscasts.com/episodes/305-authentication-with-warden?view=asciicast