Authorizing Requests Lab (CodeGrade)

Learning Goals


Key Vocab


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 Flask API backend and a React frontend. To get set up, run:

$ pipenv install; pipenv shell
$ npm install --prefix client
$ cd server
$ flask db upgrade
$ python seed.py

You can work on this lab by running the tests with pytest -x. 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 Flask server with:

$ python app.py

And you can run React in another terminal from the root project directory 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 two new views: MemberOnlyIndex and MemberOnlyArticle.

Your goal is to add the following functionality to the new views:


Resources

Powered by Forestry.md