Coder Social home page Coder Social logo

dakotalmartinez / phase-4-authorizing-requests-lab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-curriculum/phase-4-authorizing-requests-lab

0.0 1.0 0.0 408 KB

License: Other

Ruby 77.85% HTML 3.40% JavaScript 16.72% CSS 2.02%

phase-4-authorizing-requests-lab's Introduction

Authorizing Requests Lab

Learning Goals

  • Use the session hash to authorize a user to perform actions

Introduction

In this lab, we'll continue working on the blog site, and add some features that only logged in users have access to.

There is some starter code in place for a Rails API backend and a React frontend. To get set up, run:

$ bundle install
$ rails db:migrate db:seed
$ npm install --prefix client

You can work on this lab by running the tests with learn test. It will also be helpful to see what's happening during the request/response cycle by running the app in the browser. You can run the Rails server with:

$ rails s

And you can run React in another terminal with:

$ npm start --prefix client

You don't have to make any changes to the React code to get this lab working.

Instructions

Now that we've got the basic login feature working, let's reward our logged in users with some bonus content that only users who have logged in will be able to access!

We added a new attribute to our articles, is_member_only, to reflect whether the article should only be available to authorized users of the site. We also created a new MembersOnlyArticlesController class to display these exclusive articles to our logged in users.

Your goal is to add the following functionality to the MembersOnlyArticlesController:

  • If a user is not signed in, the #index and #show actions should return a status code of 401 unauthorized, along with an error message
  • If the user is signed in, the #index and #show actions should return the JSON data for the members-only articles.

Resources

phase-4-authorizing-requests-lab's People

Contributors

ihollander avatar dakotalmartinez avatar lizbur10 avatar

Watchers

James Cloos 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.