Code Monkey home page Code Monkey logo

symmetrical-succotash's Introduction

Kickball Manager

Use this repo as a template for your deliverable.

Learning Objectives

  • Manage row level security in Supabase by adding policies for retrieving, creating, updating and deleting rows
  • Add Protected Routes in React

Description

For this deliverable, you will need to add Row Level Security to your Supabase database as well as Protected Routes in React to secure your application.

  1. Create a Supabase table called teams which has the following columns

    column
    id
    name
    city
    state
    created_at

    Some seed data:

INSERT INTO teams (name, city, state)
 VALUES
 ('Rip City Kickers', 'Portland', 'OR'),
 ('Bridge City Sneakers', 'Portland', 'OR'),
 ('Lakeville Thuderfeet', 'Lake Oswego', 'OR'),
 ('Mt. Hoodies', 'Mt. Hood', 'OR');
  1. In the "Authentication" section of Supabase enable row level security for the teams table

  2. Add policies for INSERT, DELETE, READ and UPDATE

    Action Policy Description
    READ true Enable read access to all users
    INSERT role() = 'authenticated'::text) Enable insert for authenticated users only
    DELETE role() = 'authenticated'::text) Enable delete for authenticated users only
    UPDATE (role() = 'authenticated'::text) Enable update for authenticated users only

Note, supabase policies can be done with a check or a using expression -- for the update to work, it needs to be on the using expression. See here for details.

  1. Using the provided <ProtectedRoute> component to properly protect the /new, and /edit routes -- users should be redirected to the sign-in page if they try to access those routes while not signed in.

Acceptance Criteria

  • An authorized user can add a new team
  • An authorized user can edit an existing team
  • An authorized user can delete an existing team
  • Only authorized viewers should see Links to edit / delete
  • Unauthorized users are redirected to sign in if they try to access the new or edit routes
  • All users can view the /teams page
  • Tests should continue to pass (you can update snapshots)

Rubric

Task Points
All users can see a list of teams (authorized or unauthorized) 2
An authorized user can create a new team 2
An authorized user can edit a team 2
An authorized user can delete a team 2
Unauthorized users are redirected to sign in if they try to access new or edit routes 2

symmetrical-succotash's People

Contributors

forestheims avatar

Watchers

 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.