Code Monkey home page Code Monkey logo

has_secure_password_lab's Introduction

has_secure_password

Objectives

We're going to make a Rails app that covers a simple authentication flow: users can create accounts, log in, and log out.

Introduction

Our app has three pages:

  1. A signup page, where the user enters their username (as name), password, and password confirmation.
  2. A login page, where the user submits their username (as name) and password and are then logged in.
  3. A user homepage, which says, "Hi, #{name}."

We're not covering validations in this lab, so don't worry about those. (Password validations are hard to get right anyway; it's surprisingly easy to produce rules which decrease password security rather than enhance it.)

Users should not be able to log in if they enter an incorrect password. Just redirect them back to the login page. If you want to present an error, you can either return an HTTP error from the controller and catch it with Javascript, or set a flash.

Instructions

  1. Create a User model and migrations.

  2. Create a Users controller. It should respond to new with the signup form, and respond to create by creating a new user.

  3. Create a Sessions controller and the appropriate actions.

  4. Create a user homepage. You can either create a controller for it (a WelcomeController is a reasonable thing that you'll see frequently), or you can make it an action in the User's controller.

Happy coding.

has_secure_password_lab's People

Contributors

ahimmelstoss avatar blake41 avatar danielseehausen avatar dependabot[bot] avatar drakeltheryuujin avatar gj avatar ihollander avatar lizbur10 avatar lkwlala avatar maxwellbenton avatar mendelb avatar queerviolet avatar rrcobb avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

has_secure_password_lab's Issues

The lesson calls for the use of username, but the tests call for name only

The lesson calls for the implementation of a "username" attribute for Users, but only tests for a "name" attribute. It even suggests interpolating "Hi, #{username}" at a type of home page. This results in an error of "undefined method username for User object" because the tests are only instantiating users with the "name" attribute. This can be remedied by either changing the lesson from "username" to "name", or by changing the tests from "name" to "username". Thank you.

Local Tests not turning green or red

I finished the lab and was able to do a pull request, but learn is not responding to the local test. This makes me unable to 100% complete the lab.

No repo

There is no repo to run from learn.co. Either using learn open or the github link

users_controller_spec.rb expecting redirect_to may be bad practice

 it "redirects you if your password and confirmation don't match" do
      typo = steven.merge(password_confirmation: 'uni111verse')
      post :create, params: { user: typo }
      expect(response).to redirect_to(controller: 'users', action: 'new')
 end

We should be able to use render :new, that way the user's name is still pre-fill in the text field. However, the test is expecting us to use redirect_to

config/routes.rb file defines /users/new twice

@Lukeghenco: as mentioned, the /users/new route is defined twice in the solution branch, once as get '/users/new' (line 2) and again as resources :user (line 8). Since the lab's README specs that the UsersController should response to #new and #create actions, would it make sense to remove line 2, revise line 8 to resources :user, only: [:new, :create]?

This lab is still broken

The learn open link still does not work for this lab, and the only repository available has all of the solutions.

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.