Mod 2 - project  (hashed passwords/sessions)
Week 6 at Flatiron bootcamp is project week.
For this project we used Rails for our back end, written in Ruby. We followed the MVC architecture pattern and was conscious to use RESTful routes while demonstrating all CRUD actions.
This is the third of three posts about my Mod2 project at Flatiron school where my partner and I created an app called CardFlash. Today Iâm covering Hashed Passwords and Sessions.Â
Hashed Passwords
After building out the login page I was a little disappointed. The only field I provided was for a username. I mean, whats the point of having a personal username if anyone could just sign in and use it? Â
Time to figure out Hashed passwords.Â
1. Add bcrypt gem to your gem file.Â
https://rubygems.org/gems/bcrypt/versions/3.1.12
2. Add password_object to your user table. In console:
rails g migration add_password_digest_to_users password_digest:string
3. Add has_secure_password to your model.
While you are in your model, why not add some validations?
After that, in your login form, you can now add :password and :password_confirmation keys.Â
Cool. Test it out... you should be good to go!
Sessions
1. in the application_controller, add the following methods:
helper_method :current_userÂ
sets up :current_user as a helper method so you can use it in a view.Â
before_action :current_user
before anything is done in this controller, :current_user will run. By putting this in Application Controller, :current_user will run before any method in any controller that inherits ActionController (which is basically all of them!)
This is how you are able to call on current_user from any model, and thus able to access user information from anywhere on the website.Â
Want to see some screenshots of our final site?????????Â
CHECK IT OUT!!!! (we made this near easter so check the sweet colors)
/home
/collections
/flashcards
/User/id
/signup
/login
flashcards/new
collections/id
collections/new
flashcards/id/edit
There is no page for destroying a card... but you can do that too!
Thanks!!!!
~~~~~ EASTER EGGS~~~~~~~
custom tags
bootstrap styling
css stylesheetÂ
footer with links to our blogs
~~~~~~~~~~~~~~~~~~~~~~~~


















