This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bcrypt from 'bcryptjs'; | |
| import jwt from 'jsonwebtoken'; | |
| /* JWT secret key */ | |
| const KEY = process.env.JWT_KEY; | |
| /* Users collection sample */ | |
| const USERS = [ | |
| { | |
| id: 1, | |
| email: 'example1@example.com', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Router from 'next/router'; | |
| import Cookies from 'js-cookie'; | |
| import jwt from 'jsonwebtoken'; | |
| const SECRET_KEY = process.env.JWT_KEY; | |
| /* | |
| * @params {jwtToken} extracted from cookies | |
| * @return {object} object of extracted token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "nextjs-jwt", | |
| "version": "0.1.0", | |
| "private": true, | |
| "scripts": { | |
| "dev": "next dev", | |
| "build": "next build", | |
| "start": "next start" | |
| }, | |
| "dependencies": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import Link from 'next/link'; | |
| /* middleware */ | |
| import { | |
| absoluteUrl, | |
| getAppCookies, | |
| verifyToken, | |
| setLogout, | |
| } from '../middleware/utils'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react'; | |
| import Link from 'next/link'; | |
| import Router from 'next/router'; | |
| import Cookies from 'js-cookie'; | |
| /* middleware */ | |
| import { | |
| absoluteUrl, | |
| getAppCookies, | |
| verifyToken, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function FormLogin({ props }) { | |
| const { | |
| onSubmitHandler, | |
| onChangeHandler, | |
| stateFormData, | |
| stateFormError, | |
| stateFormMessage, | |
| } = props; | |
| return ( | |
| <form className="form-login card" method="POST" onSubmit={onSubmitHandler}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* next.js head */ | |
| import Head from 'next/head'; | |
| /* components */ | |
| import Header from '../header/Header'; | |
| import Footer from '../footer/Footer'; | |
| export default function Layout({ | |
| children, | |
| title = 'Next.js with JWT Authentication | A boilerplate JWT Authentication and Next.js from dyarfi.github.io', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| generator client { | |
| provider = "prisma-client-js" | |
| } | |
| datasource db { | |
| provider = "postgresql" | |
| url = env("DATABASE_URL") | |
| } | |
| model Job { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Your Website Title</title> | |
| <meta name="description" content="Your Website Description"> | |
| </head> | |
| <body> | |
| <header class="header"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| serverRuntimeConfig: { | |
| // Will only be available on the server side | |
| mySecret: 'secret', | |
| secretKey: 'secretKey', | |
| jwtToken: 'JwtToken', | |
| }, | |
| publicRuntimeConfig: { | |
| // Will be available on both server and client | |
| // Pass through env variables |