Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
81d5a2b
set up project
MyrtheDullaart Jul 10, 2024
79bef7e
set up forms
MyrtheDullaart Jul 10, 2024
4e00238
add functions to register user
MyrtheDullaart Jul 10, 2024
6a45060
set up routers and controllers
MyrtheDullaart Jul 10, 2024
dafdd3d
add domain and controllers to register user
MyrtheDullaart Jul 10, 2024
1f4f379
add functions to handle login frontend
MyrtheDullaart Jul 10, 2024
0417025
add functions to log in user backend
MyrtheDullaart Jul 10, 2024
009259c
add function to get all movies
MyrtheDullaart Jul 10, 2024
c23af30
add functions to create movie frontend
MyrtheDullaart Jul 10, 2024
8d70b78
add functions to create movie backend
MyrtheDullaart Jul 10, 2024
b917348
add verify token function
MyrtheDullaart Jul 10, 2024
e00565f
add error handling
MyrtheDullaart Jul 10, 2024
834beb0
add error handling frontend
MyrtheDullaart Jul 10, 2024
837aec9
clean up code
MyrtheDullaart Jul 11, 2024
f6f97d7
add navigation
MyrtheDullaart Jul 11, 2024
4b6cc62
add functions to get movies per user
MyrtheDullaart Jul 11, 2024
d2618b4
add createcontext
MyrtheDullaart Jul 11, 2024
26844d5
add basic css
MyrtheDullaart Jul 11, 2024
8f91e59
set up jest
MyrtheDullaart Jul 11, 2024
bb00ad3
create register user tests
MyrtheDullaart Jul 11, 2024
5a49b82
create 409 test for user
MyrtheDullaart Jul 12, 2024
c74ab6d
add functions front and back end to view users as admin
MyrtheDullaart Jul 12, 2024
04f114b
add functions front and backend to delete user as admin
MyrtheDullaart Jul 12, 2024
ed092bb
clean up code
MyrtheDullaart Jul 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://boolean_owner:[email protected]/authchallenge?schema=public"

TEST_DATABASE_URL= "postgresql://boolean_owner:[email protected]/testdbchallenge?sslmode=require"

VITE_PORT=4000

JWT_SECRET="RandomString"
21 changes: 21 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { browser: true, es2020: true, "node": true, "jest": true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Env
.env

# Logs
logs
*.log
Expand Down
37 changes: 5 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
# Authentication Challenge
# React + Vite

## Learning Objectives
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

- Use a token-based approach to authorise access to API resources
- Use a hashing library to encrypt sensitive information
- Build a front-end application that interacts with a bearer-auth protected API
Currently, two official plugins are available:

## Introduction

You are tasked with building a small frontend application containing 3 forms and a list. There is a screenshot at the
bottom of this document that gives you an idea of what to aim for. As you'll be able to see, it doesn't have to *look*
good so don't spend time on styling!

The flow of the application you build looks like this:

1. A user fills in the register form to create their account with a hashed password
2. The user fills in the login form to get a bearer token
3. The user can then create movies once they have a valid token
4. The list of displayed movies will update as a user creates them

## Requirements

1. Both your backend _and_ your frontend must exist in this repo. We should be able to run them both together with a single command.
2. Must use React, Express and an SQL database. Everything else is fair game.
3. Good luck, have fun!

## Extension

1. Create an admin dashboard where admins can view and delete users.
2. Introduce a second type of auth. It should be a second option to the user, not a replacement for the original.

## Example solution

![](./assets/example_solution.png)
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
setupFilesAfterEnv: ['./test/setupTests.js']
}

export default config
Loading