1
0
mirror of synced 2026-02-04 12:08:33 -05:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Siddharth Suresh
ee99c5739c start adding index page / twoslash and add community docs 2023-03-02 23:27:22 +05:30
Siddharth Suresh
de5b6eb9a9 add introduction pages 2023-03-02 17:57:53 +05:30
Siddharth Suresh
d86bb0cf83 init nextra 2023-03-02 15:12:27 +05:30
404 changed files with 17922 additions and 23193 deletions

View File

@@ -3847,144 +3847,6 @@
"doc",
"code"
]
},
{
"login": "jeliasson",
"name": "Johan Eliasson",
"avatar_url": "https://avatars.githubusercontent.com/u/865493?v=4",
"profile": "https://github.com/jeliasson",
"contributions": [
"doc"
]
},
{
"login": "jafarlihi",
"name": "Hikmat Jafarli",
"avatar_url": "https://avatars.githubusercontent.com/u/43515211?v=4",
"profile": "https://github.com/jafarlihi",
"contributions": [
"doc",
"code"
]
},
{
"login": "maotora",
"name": "Maotora ᕙ(⇀‸↼‶)ᕗ",
"avatar_url": "https://avatars.githubusercontent.com/u/5174884?v=4",
"profile": "https://maotoramm.com",
"contributions": [
"doc",
"code"
]
},
{
"login": "vitaliemiron",
"name": "Vitalie",
"avatar_url": "https://avatars.githubusercontent.com/u/45145592?v=4",
"profile": "https://github.com/vitaliemiron",
"contributions": [
"doc",
"code"
]
},
{
"login": "nelsonmestevao",
"name": "Nelson Estevão",
"avatar_url": "https://avatars.githubusercontent.com/u/19409687?v=4",
"profile": "https://estevao.org",
"contributions": [
"doc",
"code"
]
},
{
"login": "dbrxnds",
"name": "David",
"avatar_url": "https://avatars.githubusercontent.com/u/32268383?v=4",
"profile": "https://github.com/dbrxnds",
"contributions": [
"doc",
"code",
"test"
]
},
{
"login": "gjmoed",
"name": "G.J. Moed",
"avatar_url": "https://avatars.githubusercontent.com/u/4458993?v=4",
"profile": "https://github.com/gjmoed",
"contributions": [
"doc",
"code"
]
},
{
"login": "GHKEN",
"name": "Tetsuya Fukuda",
"avatar_url": "https://avatars.githubusercontent.com/u/5304351?v=4",
"profile": "https://ghken.com",
"contributions": [
"doc",
"code"
]
},
{
"login": "nerixim",
"name": "Nikita Kamaev",
"avatar_url": "https://avatars.githubusercontent.com/u/26106502?v=4",
"profile": "https://github.com/nerixim",
"contributions": [
"doc"
]
},
{
"login": "nikola-wd",
"name": "Nikola Ivanov",
"avatar_url": "https://avatars.githubusercontent.com/u/11588823?v=4",
"profile": "https://webredone.com/",
"contributions": [
"doc"
]
},
{
"login": "jayu",
"name": "Jakub Mazurek",
"avatar_url": "https://avatars.githubusercontent.com/u/11561585?v=4",
"profile": "jayu.dev",
"contributions": [
"doc",
"code"
]
},
{
"login": "maciej-ka",
"name": "Maciej Kasprzyk",
"avatar_url": "https://avatars.githubusercontent.com/u/5403694?v=4",
"profile": "https://github.com/maciej-ka",
"contributions": [
"doc",
"code"
]
},
{
"login": "justinsmid",
"name": "Justin Smid",
"avatar_url": "https://avatars.githubusercontent.com/u/34271675?v=4",
"profile": "https://github.com/justinsmid",
"contributions": [
"doc",
"code"
]
},
{
"login": "rodobre",
"name": "rodobre",
"avatar_url": "https://avatars.githubusercontent.com/u/52138375?v=4",
"profile": "https://github.com/rodobre",
"contributions": [
"doc",
"code"
]
}
],
"contributorsPerLine": 7,

View File

@@ -1,9 +0,0 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
"blitz": patch
"@blitzjs/generator": patch
---
(feat) upgrade tslog to v4.8.2

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/next": minor
"@blitzjs/rpc": minor
---
Add ability to format the error on the server before returning it to the client.

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
Update examples of generate all in docs to include one column in model.

View File

@@ -1,9 +0,0 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
Upgrade tslog to `4.9.0`.
This due a [tslog issue](https://github.com/fullstack-build/tslog/issues/227) that causes tslog to crash when attempting to log an error whose constructor expects more than one argument.

View File

@@ -1,11 +0,0 @@
---
"blitz": minor
"@blitzjs/auth": minor
"@blitzjs/next": minor
"@blitzjs/rpc": minor
---
- New Blitz Auth Function `getAppSession`, This function will use the cookies and headers provided by the server component and returns the current session.
- New Blitz Auth Hook `useAuthenticatedAppSession`, This hook is implemented as the replacement of the BlitzPage seurity auth utilities provided for the pages directory to work with React Server Components in the Nextjs 13 app directory
- New Blitz React Server Component Wrapper, `BlitzProvider` is to be imported from setupBlitzClient in src/blitz-client.ts and to used to ideally wrap the entire application in the `RootLayout` in the root layout.ts file of next app directory.
- Fix failing tests due to the error `NextRouter is not mounted` in next 13 blitz apps

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
blitz-auth: Fix webpack from following next-auth

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/recipe-chakra-ui": patch
"@blitzjs/recipe-next-ui": patch
---
Fix LabeledTextField update on next-ui and chakra-ui recipes

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/auth": minor
"blitz": minor
---
feature: Next Auth Adapter

View File

@@ -1,7 +0,0 @@
---
"@blitzjs/next": minor
---
Fix Next 13.2 compatibility
This updates the suspense patch to work with Next.js 13.2+. Hopefully soon we can stop patching once Next.js catches up with all the other frameworks and properly [exposes the `onRecoverableError` react hook](https://github.com/vercel/next.js/discussions/36641).

View File

@@ -1,6 +0,0 @@
---
"blitz": patch
"@blitzjs/generator": patch
---
Consolidate mutations schema to new schema.{ts|js} file.

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/rpc": patch
---
Fix return type of `requestMiddlewares` in `RpcServerPlugin`

View File

@@ -1,8 +0,0 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
blitz-auth: Support for Prisma v5
Internal: Make `handle` a required paramter while updating the `session` modal.

View File

@@ -1,20 +0,0 @@
---
"@blitzjs/auth": major
"@blitzjs/codemod": minor
---
## ⚠️ Breaking Changes for Blitz Auth
Automatically upgrade using codemod
(Make sure to git commit before running this command to avoid losing changes)
```bash
npx @blitz/codemod secure-password
```
Introduce a new import path for the Blitz wrapper `SecurePassword` to fully decouple the library from `@blitzjs/auth`
```diff
- import {SecurePassword} from "@blitzjs/auth"
+ import {SecurePassword} from "@blitzjs/auth/secure-password"
```

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/auth": patch
---
Updated `useAuthenticatedBlitzContext` to now return `AuthenticatedCtx`

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": minor
---
Fix the DYNAMIC_SERVER_USAGE error for Next.js 13.3.1+

View File

@@ -1,26 +0,0 @@
---
"@blitzjs/rpc": patch
---
Fixes enormous memory consumption of the dev server by changing the default import strategy to "require" instead of "import" which in webpack causes multiple chunks to be created for each import.
## Blitz Configuration
To configure this behaviour, you can add the following to your next.config.js:
```js
/**
* @type {import('@blitzjs/next').BlitzConfig}
**/
const config = {
blitz: {
resolversDynamicImport: true,
},
}
```
When `resolversDynamicImport` is set to `true`, the import strategy will be "import" instead of "require".
### On Vercel
If you are using Vercel, `resolversDynamicImport` will be set to `true` by default, since it is better for the separate chunks to be create for serverless lambdas.

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
Make Next.js version stick to 13.4.5 when generating a new app

View File

@@ -1,6 +0,0 @@
---
"blitz": patch
---
- Removes language selection step from `blitz new` menu
- Make `formik` the default/recommended form library

View File

@@ -1,10 +0,0 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": major
"@blitzjs/rpc": patch
"blitz": patch
---
⚠️ Breaking Change:
Next.js version 13.5 or above is now required to use `@blitzjs/next`
Fix `Error: Cannot find module 'next/dist/shared/lib/router/utils/resolve-href'` by updating the location of next.js internal function.

View File

@@ -1,7 +0,0 @@
---
"@blitzjs/recipe-chakra-ui": patch
"@blitzjs/recipe-next-ui": patch
"@blitzjs/recipe-tailwind": patch
---
This change reflects the directory change from app/pages to src/pages for the receipts chakra-ui, next-ui, tailwind. It checks for which directories exists and is compatible with either versions.

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/auth": minor
---
Stop exporting `useAuthenticatedBlitzContext` from `@blitzjs/auth` this must be imported from `app/blitz-server.ts` file in order to work correctly

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Fix for tslog error `TypeError: Cannot read properties of undefined (reading 'map')` while using custom errors.

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/rpc": patch
---
Fix return type of the `invoke` method from returning type function to return the type of resolved data

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Allow `.tsx` & `.jsx` file extensions to be used for resolvers

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
fix: add missing key prop to LabelSelectField

View File

@@ -1,9 +0,0 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
"blitz": patch
"@blitzjs/generator": patch
---
Update the version of next in the new template from 13.2 to 13.3.0

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
The issue is that the version provided, "13.2", is not a valid SemVer version. A valid SemVer version must have three components: major, minor, and patch (e.g., "13.2.0").

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
blitz-rpc: Cleanup Event Listeners - Fix potential memory leak by cleaning up any residual event listeners set by blitz.

View File

@@ -46,16 +46,13 @@
"@blitzjs/recipe-theme-ui": "0.34.0-canary.0",
"@blitzjs/recipe-vanilla-extract": "0.34.0-canary.0",
"test-rpc-path-root": "0.0.0",
"test-full-auth-with-rpc": "0.0.0",
"next-blitz-auth": "0.1.0",
"test-app-dir": "0.0.0"
"test-full-auth-with-rpc": "0.0.0"
},
"changesets": [
"afraid-dancers-juggle",
"afraid-ears-repair",
"big-boats-lay",
"big-phones-bow",
"big-turtles-tease",
"blue-flowers-peel",
"blue-pigs-tan",
"brave-zebras-deny",
@@ -70,25 +67,19 @@
"calm-nails-wait",
"calm-papayas-protect",
"calm-tomatoes-drive",
"chatty-fireants-leave",
"chatty-gifts-whisper",
"chilled-carrots-own",
"chilly-candles-care",
"chilly-jeans-fix",
"chilly-nails-nail",
"clean-hats-pump",
"clean-hounds-laugh",
"clean-walls-wink",
"clever-hornets-talk",
"clever-radios-lie",
"cool-doors-invent",
"cool-horses-check",
"cuddly-pugs-crash",
"cuddly-singers-perform",
"curly-rules-speak",
"curly-seas-serve",
"curvy-days-attend",
"curvy-drinks-perform",
"cyan-bulldogs-heal",
"cyan-cars-greet",
"dirty-monkeys-greet",
@@ -100,23 +91,17 @@
"eleven-lobsters-drop",
"empty-berries-rule",
"empty-pants-search",
"empty-spiders-lay",
"empty-turkeys-wave",
"fair-carrots-guess",
"fair-kangaroos-clean",
"fair-wombats-sneeze",
"famous-kings-explain",
"fast-adults-guess",
"fast-clocks-push",
"fast-pans-impress",
"fast-papayas-grow",
"fast-toys-wash",
"fast-trainers-kneel",
"few-dogs-fetch",
"few-elephants-approve",
"few-hounds-worry",
"few-shrimps-leave",
"fifty-drinks-cry",
"flat-bees-approve",
"fluffy-coats-flow",
"fluffy-mangos-begin",
@@ -124,10 +109,7 @@
"forty-timers-rhyme",
"four-brooms-juggle",
"four-meals-fry",
"four-radios-tickle",
"four-sheep-judge",
"fresh-camels-return",
"fresh-crews-chew",
"funny-cups-pay",
"fuzzy-bees-warn",
"fuzzy-dots-cross",
@@ -140,7 +122,6 @@
"gold-horses-punch",
"good-apes-drum",
"good-insects-wink",
"good-oranges-pretend",
"gorgeous-birds-warn",
"gorgeous-buses-scream",
"gorgeous-games-obey",
@@ -170,7 +151,6 @@
"khaki-ducks-cheer",
"khaki-pens-rest",
"kind-walls-suffer",
"large-hairs-battle",
"late-steaks-give",
"lazy-maps-sort",
"lemon-games-press",
@@ -179,7 +159,6 @@
"lemon-teachers-jam",
"light-donkeys-double",
"light-squids-draw",
"little-cycles-hang",
"little-pears-ring",
"long-bees-hope",
"long-dancers-jog",
@@ -189,34 +168,25 @@
"lovely-colts-share",
"lucky-cows-try",
"lucky-months-guess",
"lucky-teachers-sleep",
"lucky-years-turn",
"many-fans-fetch",
"mean-ears-speak",
"mean-gorillas-reply",
"modern-cameras-pull",
"modern-games-dream",
"modern-ligers-behave",
"moody-bags-walk",
"moody-crews-travel",
"moody-spoons-rhyme",
"moody-squids-cheer",
"nasty-suns-wash",
"nervous-beds-travel",
"nervous-dolls-rule",
"nervous-shrimps-serve",
"new-coats-turn",
"new-olives-protect",
"nice-boxes-travel",
"nice-cats-lay",
"nice-deers-dream",
"nice-starfishes-live",
"nine-bags-rhyme",
"nine-birds-confess",
"nine-onions-admire",
"ninety-lies-press",
"ninety-pets-heal",
"ninety-pots-learn",
"ninety-rice-tickle",
"odd-bears-run",
"olive-bees-buy",
@@ -230,10 +200,8 @@
"perfect-eyes-repeat",
"perfect-trains-double",
"plenty-bottles-swim",
"plenty-gifts-provide",
"plenty-kiwis-greet",
"polite-lizards-love",
"poor-crabs-drum",
"poor-peas-lick",
"poor-penguins-look",
"poor-shrimps-think",
@@ -243,7 +211,6 @@
"purple-donkeys-smash",
"purple-jars-begin",
"purple-singers-greet",
"quick-crews-occur",
"quick-cycles-confess",
"quick-dots-fetch",
"quiet-feet-travel",
@@ -258,7 +225,6 @@
"rotten-rocks-remember",
"rude-trainers-visit",
"serious-mugs-leave",
"shaggy-boxes-exercise",
"shaggy-carpets-brake",
"sharp-falcons-begin",
"sharp-olives-sip",
@@ -268,16 +234,13 @@
"silent-colts-reply",
"silent-lies-run",
"silly-apricots-share",
"silly-peas-work",
"silly-shoes-agree",
"six-apricots-kick",
"sixty-rockets-count",
"slimy-humans-impress",
"slimy-needles-taste",
"slow-impalas-tap",
"slow-walls-camp",
"slow-walls-poke",
"small-monkeys-battle",
"small-socks-confess",
"smooth-planets-admire",
"smooth-rice-clap",
@@ -295,7 +258,6 @@
"stale-jobs-drum",
"stale-parents-yawn",
"strong-apes-reply",
"strong-chicken-study",
"strong-keys-lie",
"stupid-rabbits-jump",
"stupid-walls-sell",
@@ -304,10 +266,8 @@
"swift-glasses-laugh",
"swift-poets-travel",
"tall-meals-learn",
"tall-radios-clean",
"tame-keys-reply",
"tame-pumpkins-nail",
"tame-rocks-unite",
"tasty-maps-fetch",
"tasty-news-collect",
"tasty-squids-sin",
@@ -345,9 +305,7 @@
"wicked-rings-walk",
"wise-eels-visit",
"wise-frogs-give",
"wise-lies-relate",
"wise-rabbits-complain",
"yellow-numbers-serve",
"young-birds-talk"
]
}

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
Remove rouge `console.log` during start

View File

@@ -1,9 +0,0 @@
---
"@blitzjs/next": patch
"blitz": patch
"@blitzjs/generator": patch
---
- Updates `ts-log` peer dependency to `4.9.0`
- Removes `javascript` from `blitz new` menu
- Hot Fix the `Update Schema` when using blitz generator

View File

@@ -1,6 +0,0 @@
---
"blitz": patch
"@blitzjs/generator": patch
---
Multiple fields forms using templates during generation - TODO

View File

@@ -1,68 +0,0 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
### Now we can configure Blitz RPC in the following way,
In your `[[...blitz]].ts` api file you can see the following settings
```ts
logging?: {
/**
* allowList Represents the list of routes for which logging should be enabled
* If whiteList is defined then only those routes will be logged
*/
allowList?: string[]
/**
* blockList Represents the list of routes for which logging should be disabled
* If blockList is defined then all routes except those will be logged
*/
blockList?: string[]
/**
* verbose Represents the flag to enable/disable logging
* If verbose is true then Blitz RPC will log the input and output of each resolver
*/
verbose?: boolean
/**
* disablelevel Represents the flag to enable/disable logging for a particular level
*/
disablelevel?: "debug" | "info"
}
```
```ts
import { rpcHandler } from "@blitzjs/rpc"
import { api } from "src/blitz-server"
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
logging: {
...
}
})
)
```
Example:
```ts
export default api(
rpcHandler({
onError: console.log,
formatError: (error) => {
error.message = `FormatError handler: ${error.message}`
return error
},
logging: {
verbose: true,
blockList: ["getCurrentUser", ...], //just write the resolver name [which is the resolver file name]
},
})
)
```
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/auth": patch
"blitz": patch
---
Fix Next-Auth integration: `Unable to use next-auth with provider: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]`

View File

@@ -1,67 +0,0 @@
---
"@blitzjs/auth": patch
"@blitzjs/rpc": patch
"blitz": patch
---
feature: Nextjs 13 App Directory Utility Methods
### 🔧 New Blitz Auth Hook `useAuthenticatedBlitzContext`
This hook is implemented as the replacement of the [`BlitzPage` seurity auth utilities](https://blitzjs.com/docs/authorization#secure-your-pages) provided for the pages directory to work with React Server Components in the Nextjs 13 app directory
It can be used in any asynchronous server component be it in `page.ts` or in the layouts in `layout.ts`
It uses the new [`redirect` function](https://beta.nextjs.org/docs/api-reference/redirect) to provide the required authorization in server side
#### API
```ts
useAuthenticatedBlitzContext({
redirectTo,
redirectAuthenticatedTo,
role,
}: {
redirectTo?: string | RouteUrlObject
redirectAuthenticatedTo?: string | RouteUrlObject | ((ctx: Ctx) => string | RouteUrlObject)
role?: string | string[]
}): Promise<void>
```
#### Usage
**Example Usage in React Server Component in `app` directory in Next 13**
```ts
import {getAppSession, useAuthenticatedBlitzContext} from "src/blitz-server"
...
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
role: ["admin"],
redirectAuthenticatedTo: "/dashboard",
})
```
### 🔧 New Blitz RPC Hook `invokeResolver`
#### API
```ts
invokeResolver<T extends (...args: any) => any, TInput = FirstParam<T>>(
queryFn: T,
params: TInput,
): Promise<PromiseReturnType<T>>
```
#### Example Usage
```ts
...
import {invokeResolver, useAuthenticatedBlitzContext} from "../src/blitz-server"
import getCurrentUser from "../src/users/queries/getCurrentUser"
export default async function Home() {
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
})
const user = await invokeResolver(getCurrentUser, null)
...
```

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
Fix log formatting to not show the path of blitz rpc

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/auth": patch
---
Fix: Add missing entry to expose next-auth adapter in Blitz Auth

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/recipe-tailwind": minor
---
support both directory style in tailwind recipe

View File

@@ -7,8 +7,8 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
jobs:
@@ -17,13 +17,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.6.5
version: 7.11.0
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 16
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
@@ -38,13 +38,13 @@ jobs:
name: Build
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.6.5
version: 7.11.0
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 16
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- name: Build
@@ -62,20 +62,20 @@ jobs:
- windows-latest
fail-fast: false
env:
NODE_VERSION: 18
NODE_VERSION: 16
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PNPM
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.6.5
version: 7.11.0
- name: Setup node@16
uses: actions/setup-node@v2
with:
node-version: 18
node-version: 16
cache: "pnpm"
- name: Install dependencies
@@ -111,7 +111,7 @@ jobs:
echo "folders=$folders" >> $GITHUB_OUTPUT
Integration-Tests:
name: "Integration Test: ${{matrix.folder}} @ ${{ matrix.os }}"
name: "Integration Test: ${{matrix.folder}} @ ${{ matrix.os }} "
needs: [find-integration-tests]
strategy:
matrix:
@@ -124,39 +124,32 @@ jobs:
steps:
- run: echo ${{matrix.folder}}
- name: Checkout
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: actions/checkout@v3
- name: Setup PNPM
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 8.6.5
version: 7.11.0
- name: Setup node@18
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
- name: Setup node@${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: 18
node-version: ${{ matrix.NODE_VERSION }}
cache: "pnpm"
- name: Install dependencies
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: pnpm install --frozen-lockfile
shell: bash
- name: Install playwright
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: |
pnpx playwright@1.28.0 install --with-deps
pnpx playwright@1.28.0 install --with-deps
shell: bash
- name: Build
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: pnpm build
shell: bash
- name: Test Packages
if: matrix.folder != 'next-13-app-dir' || matrix.os != 'windows-latest'
run: pnpm test -- --filter=./integration-tests/${{matrix.folder}}
shell: bash

View File

@@ -99,3 +99,4 @@ jobs:
repo: context.repo.repo,
body: '```\n' + process.env.MESSAGE + '\n```',
})

View File

@@ -1,6 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
pnpm manypkg check
# pnpm manypkg check
# pnpm lint
pnpm pretty-quick --staged
# pnpm pretty-quick --staged

1
.npmrc
View File

@@ -1,5 +1,4 @@
save-exact=true
dedupe-peer-dependents=true
strict-peer-dependencies=false
public-hoist-pattern[]=secure-password

View File

@@ -6,7 +6,7 @@
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
</a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-420-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-406-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
@@ -94,11 +94,6 @@ Your financial contributions help ensure Blitz continues to be developed and mai
<td><a aria-label="Boostry" href="https://boostry.co.jp/?utm_source=BlitzJS&utm_medium=sponsorship&utm_campaign=BlitzJS_Sponsorship_2021">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/boostry.svg" width="200px">
</a></td>
<td>
<a aria-label="Byteflow" href="https://byteflow.app/?ref=blitzjs">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/byteflow.png" width="70px">
</a>
</td>
</tr>
</table>
@@ -126,11 +121,9 @@ Your financial contributions help ensure Blitz continues to be developed and mai
<table>
<tr>
<td>
<a aria-label="Flightcontrol" href="https://www.flightcontrol.dev?ref=blitzjs">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/flightcontrol.png" width="400px">
</a>
</td>
</tr>
</table>
@@ -725,24 +718,6 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="sweetliquid.me"><img src="https://avatars.githubusercontent.com/u/18693190?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sweetliquid</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=sweetliquid" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/exKAZUu"><img src="https://avatars.githubusercontent.com/u/436237?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sakamoto, Kazunori</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=exKAZUu" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=exKAZUu" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/jeliasson"><img src="https://avatars.githubusercontent.com/u/865493?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Johan Eliasson</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jeliasson" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/jafarlihi"><img src="https://avatars.githubusercontent.com/u/43515211?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hikmat Jafarli</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jafarlihi" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=jafarlihi" title="Code">💻</a></td>
<td align="center"><a href="https://maotoramm.com"><img src="https://avatars.githubusercontent.com/u/5174884?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maotora ᕙ(⇀‸↼‶)ᕗ</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=maotora" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=maotora" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vitaliemiron"><img src="https://avatars.githubusercontent.com/u/45145592?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vitalie</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Code">💻</a></td>
<td align="center"><a href="https://estevao.org"><img src="https://avatars.githubusercontent.com/u/19409687?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nelson Estevão</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/dbrxnds"><img src="https://avatars.githubusercontent.com/u/32268383?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/gjmoed"><img src="https://avatars.githubusercontent.com/u/4458993?v=4?s=100" width="100px;" alt=""/><br /><sub><b>G.J. Moed</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://ghken.com"><img src="https://avatars.githubusercontent.com/u/5304351?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tetsuya Fukuda</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/nerixim"><img src="https://avatars.githubusercontent.com/u/26106502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikita Kamaev</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nerixim" title="Documentation">📖</a></td>
<td align="center"><a href="https://webredone.com/"><img src="https://avatars.githubusercontent.com/u/11588823?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikola Ivanov</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nikola-wd" title="Documentation">📖</a></td>
<td align="center"><a href="jayu.dev"><img src="https://avatars.githubusercontent.com/u/11561585?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jakub Mazurek</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jayu" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=jayu" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/maciej-ka"><img src="https://avatars.githubusercontent.com/u/5403694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maciej Kasprzyk</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=maciej-ka" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=maciej-ka" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/justinsmid"><img src="https://avatars.githubusercontent.com/u/34271675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Justin Smid</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=justinsmid" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=justinsmid" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/rodobre"><img src="https://avatars.githubusercontent.com/u/52138375?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rodobre</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=rodobre" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=rodobre" title="Code">💻</a></td>
</tr>
</table>
<!-- markdownlint-restore -->

View File

@@ -1,7 +0,0 @@
# 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="file:./dev.db"

View File

@@ -1,3 +0,0 @@
{
"extends": "next/core-web-vitals"
}

View File

@@ -1,38 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
.vscode

View File

@@ -1,205 +0,0 @@
# next-blitz-auth
## 0.1.1-beta.10
### Patch Changes
- Updated dependencies [30fd61316]
- Updated dependencies [3ddb57072]
- Updated dependencies [fe8c937d2]
- blitz@2.0.0-beta.34
- @blitzjs/auth@2.0.0-beta.34
- @blitzjs/next@2.0.0-beta.34
- @blitzjs/rpc@2.0.0-beta.34
- @blitzjs/config@2.0.0-beta.34
## 0.1.1-beta.9
### Patch Changes
- Updated dependencies [19898a488]
- Updated dependencies [6811eab1a]
- Updated dependencies [022392c12]
- @blitzjs/rpc@2.0.0-beta.33
- blitz@2.0.0-beta.33
- @blitzjs/next@2.0.0-beta.33
- @blitzjs/auth@2.0.0-beta.33
- @blitzjs/config@2.0.0-beta.33
## 0.1.1-beta.8
### Patch Changes
- Updated dependencies [82649f341]
- Updated dependencies [8b01175b4]
- blitz@2.0.0-beta.32
- @blitzjs/next@2.0.0-beta.32
- @blitzjs/auth@2.0.0-beta.32
- @blitzjs/rpc@2.0.0-beta.32
- @blitzjs/config@2.0.0-beta.32
## 0.1.1-beta.7
### Patch Changes
- Updated dependencies [90f1741da]
- Updated dependencies [df3265b85]
- @blitzjs/auth@2.0.0-beta.31
- blitz@2.0.0-beta.31
- @blitzjs/rpc@2.0.0-beta.31
- @blitzjs/next@2.0.0-beta.31
- @blitzjs/config@2.0.0-beta.31
## 0.1.1-beta.6
### Patch Changes
- Updated dependencies [c5572bec6]
- Updated dependencies [727734955]
- @blitzjs/auth@2.0.0-beta.30
- blitz@2.0.0-beta.30
- @blitzjs/rpc@2.0.0-beta.30
- @blitzjs/next@2.0.0-beta.30
- @blitzjs/config@2.0.0-beta.30
## 0.1.1-beta.5
### Patch Changes
- Updated dependencies [b6b9a1c5a]
- Updated dependencies [61888d1a3]
- @blitzjs/auth@2.0.0-beta.29
- blitz@2.0.0-beta.29
- @blitzjs/rpc@2.0.0-beta.29
- @blitzjs/next@2.0.0-beta.29
- @blitzjs/config@2.0.0-beta.29
## 0.1.1-beta.4
### Patch Changes
- Updated dependencies [5166e5e03]
- Updated dependencies [2533caf48]
- Updated dependencies [c7ac86b85]
- Updated dependencies [1bb3a6556]
- @blitzjs/auth@2.0.0-beta.28
- @blitzjs/next@2.0.0-beta.28
- @blitzjs/rpc@2.0.0-beta.28
- blitz@2.0.0-beta.28
- @blitzjs/config@2.0.0-beta.28
## 0.1.1-beta.3
### Patch Changes
- Updated dependencies [eda14fa8a]
- Updated dependencies [3d004dc41]
- Updated dependencies [29c2b029a]
- @blitzjs/next@2.0.0-beta.27
- @blitzjs/rpc@2.0.0-beta.27
- @blitzjs/auth@2.0.0-beta.27
- blitz@2.0.0-beta.27
- @blitzjs/config@2.0.0-beta.27
## 0.1.1-beta.2
### Patch Changes
- Updated dependencies [e82a79be5]
- Updated dependencies [38d945a3f]
- @blitzjs/auth@2.0.0-beta.26
- @blitzjs/next@2.0.0-beta.26
- @blitzjs/rpc@2.0.0-beta.26
- blitz@2.0.0-beta.26
- @blitzjs/config@2.0.0-beta.26
## 0.1.1-beta.1
### Patch Changes
- Updated dependencies [f84d77a42]
- @blitzjs/rpc@2.0.0-beta.25
- @blitzjs/next@2.0.0-beta.25
- @blitzjs/auth@2.0.0-beta.25
- @blitzjs/config@2.0.0-beta.25
- blitz@2.0.0-beta.25
## 0.1.1-beta.0
### Patch Changes
- 37aeaa7fa: feature: Nextjs 13 App Directory Utility Methods
### 🔧 New Blitz Auth Hook `useAuthenticatedBlitzContext`
This hook is implemented as the replacement of the [`BlitzPage` seurity auth utilities](https://blitzjs.com/docs/authorization#secure-your-pages) provided for the pages directory to work with React Server Components in the Nextjs 13 app directory
It can be used in any asynchronous server component be it in `page.ts` or in the layouts in `layout.ts`
It uses the new [`redirect` function](https://beta.nextjs.org/docs/api-reference/redirect) to provide the required authorization in server side
#### API
```ts
useAuthenticatedBlitzContext({
redirectTo,
redirectAuthenticatedTo,
role,
}: {
redirectTo?: string | RouteUrlObject
redirectAuthenticatedTo?: string | RouteUrlObject | ((ctx: Ctx) => string | RouteUrlObject)
role?: string | string[]
}): Promise<void>
```
#### Usage
**Example Usage in React Server Component in `app` directory in Next 13**
```ts
import {getAppSession, useAuthenticatedBlitzContext} from "src/blitz-server"
...
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
role: ["admin"],
redirectAuthenticatedTo: "/dashboard",
})
```
### 🔧 New Blitz RPC Hook `invokeResolver`
#### API
```ts
invokeResolver<T extends (...args: any) => any, TInput = FirstParam<T>>(
queryFn: T,
params: TInput,
): Promise<PromiseReturnType<T>>
```
#### Example Usage
```ts
...
import {invokeResolver, useAuthenticatedBlitzContext} from "../src/blitz-server"
import getCurrentUser from "../src/users/queries/getCurrentUser"
export default async function Home() {
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
})
const user = await invokeResolver(getCurrentUser, null)
...
```
- Updated dependencies [cadefb88e]
- Updated dependencies [6f18cbdc9]
- Updated dependencies [acc07ce94]
- Updated dependencies [ea7561b8e]
- Updated dependencies [9529dbd6f]
- Updated dependencies [ea7561b8e]
- Updated dependencies [6e88a847f]
- Updated dependencies [37aeaa7fa]
- blitz@2.0.0-beta.24
- @blitzjs/auth@2.0.0-beta.24
- @blitzjs/next@2.0.0-beta.24
- @blitzjs/rpc@2.0.0-beta.24
- @blitzjs/config@2.0.0-beta.24

View File

@@ -1,26 +0,0 @@
# Next.js 13 + Blitz Auth
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) + [`Blitz Auth`](https://blitzjs.com/docs/auth).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can go to the `/signup` page and create a new account.
## Learn More
To learn more about Next.js and Blitz.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Blitz.js Documentation](https://blitzjs.com/docs/) — learn about Blitz.js.
- [Blitz Auth Documentation](https://blitzjs.com/docs/auth) — learn about Blitz Auth plugin.

View File

@@ -1,8 +0,0 @@
import {useAuthenticatedBlitzContext} from "@blitzjs/auth"
export default async function RootLayout({children}: {children: React.ReactNode}) {
await useAuthenticatedBlitzContext({
redirectAuthenticatedTo: "/",
})
return <>{children}</>
}

View File

@@ -1,13 +0,0 @@
"use client"
import {LoginForm} from "../../../src/auth/components/LoginForm"
import {useRouter} from "next/navigation"
import {useSearchParams} from "next/navigation"
const LoginPage = () => {
const router = useRouter()
const searchParams = useSearchParams()
return <LoginForm onSuccess={(_user) => {}} />
}
export default LoginPage

View File

@@ -1,11 +0,0 @@
"use client"
import {useRouter} from "next/navigation"
import SignupForm from "../../../src/auth/components/SignupForm"
const SignUp = () => {
const router = useRouter()
return <SignupForm onSuccess={() => router.push("/")} />
}
export default SignUp

View File

@@ -1,24 +0,0 @@
"use client" // Error components must be Client components
import React, {useEffect} from "react"
export default function Error({error, reset}: {error: Error; reset: () => void}) {
useEffect(() => {
// Log the error to an error reporting service
console.error(error)
}, [error])
return (
<div>
<h2>Something went wrong!</h2>
<button
onClick={
// Attempt to recover by trying to re-render the segment
() => reset()
}
>
Try again
</button>
</div>
)
}

View File

@@ -1,57 +0,0 @@
import "src/styles/globals.css"
import {BlitzProvider} from "../src/blitz-client"
import styles from "src/styles/Home.module.css"
export default function RootLayout({children}: {children: React.ReactNode}) {
return (
<html lang="en">
<head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</head>
<body>
<BlitzProvider>
<div className={styles.globe} />
<div className={styles.container}>
<div className={styles.toastContainer}>
<p>
<strong>Congrats!</strong> Your app is ready, including user sign-up and log-in.
</p>
</div>
<main className={styles.main}>
<div className={styles.wrapper}>
<div className={styles.header}>
<div className={styles.logo}>
<svg viewBox="0 0 165 66">
<path d="M104.292 56.033C104.292 56.408 104.206 56.6636 104.036 56.8C103.9 56.9363 103.627 57.0045 103.218 57.0045H99.7409C99.4001 57.0045 99.1615 56.9533 99.0251 56.8511C98.8888 56.7147 98.8206 56.4932 98.8206 56.1864L98.9229 19.8324C98.9229 19.3211 99.1444 19.0654 99.5876 19.0654H103.627C103.839 19.0654 104.292 19.0672 104.292 19.0672V19.8324V56.033ZM64.3531 57.0081C64.1145 57.0081 63.927 56.9399 63.7906 56.8035C63.6543 56.6672 63.5861 56.4968 63.5861 56.2922V19.9383C63.5861 19.3588 63.8588 19.069 64.4042 19.069H76.829C81.533 19.069 85.1463 19.9212 87.6687 21.6256C90.1912 23.2958 91.4524 25.7331 91.4524 28.9373C91.4524 30.9484 90.924 32.6528 89.8673 34.0504C88.8106 35.4138 87.1063 36.5217 84.7543 37.3739C84.6179 37.4079 84.5497 37.4932 84.5497 37.6295C84.5497 37.7318 84.6179 37.7999 84.7543 37.834C87.2767 38.5158 89.1686 39.5895 90.4298 41.0553C91.7251 42.521 92.3727 44.4469 92.3727 46.833C92.3727 50.2418 91.0945 52.7983 88.5379 54.5027C85.9814 56.1729 82.2318 57.0081 77.2892 57.0081H64.3531ZM77.5448 35.5843C79.6923 35.5843 81.516 35.1071 83.0158 34.1526C84.5157 33.1982 85.2656 31.6983 85.2656 29.6531C85.2656 27.6079 84.5157 26.0569 83.0158 25.0002C81.5501 23.9435 79.5219 23.4151 76.9313 23.4151H70.5399C70.0286 23.4151 69.7729 23.6367 69.7729 24.0798V34.8684C69.7729 35.3457 69.9604 35.5843 70.3354 35.5843H77.5448ZM77.0335 52.662C82.9647 52.662 85.9303 50.5997 85.9303 46.4751C85.9303 44.3276 85.1633 42.7255 83.6294 41.6688C82.0955 40.6121 80.0673 40.0838 77.5448 40.0838H70.591C70.2843 40.0838 70.0627 40.1349 69.9263 40.2372C69.8241 40.3394 69.7729 40.5099 69.7729 40.7485V51.895C69.7729 52.4063 69.9604 52.662 70.3354 52.662H77.0335ZM142.707 56.8624C142.81 56.9647 142.997 57.0158 143.27 57.0158H163.876C164.387 57.0158 164.643 56.7772 164.643 56.3V53.948V53.3344H163.978H149.866C149.593 53.3344 149.457 53.2492 149.457 53.0788C149.457 52.9765 149.508 52.8572 149.61 52.7208L163.876 33.8536C164.251 33.2741 164.438 32.7628 164.438 32.3197V30.479V29.9144C164.438 29.9144 164.051 29.9165 163.876 29.9165H144.241C143.866 29.9165 143.679 30.121 143.679 30.5301V32.831C143.679 33.1037 143.713 33.2911 143.781 33.3934C143.883 33.4957 144.071 33.5468 144.344 33.5468H157.075C157.382 33.5468 157.535 33.632 157.535 33.8025L157.382 34.1092L143.219 52.9765C142.946 53.3515 142.759 53.6412 142.656 53.8457C142.588 54.0502 142.554 54.3059 142.554 54.6127V56.3C142.554 56.5727 142.605 56.7602 142.707 56.8624ZM116.929 19.0676H111.51V27.7684C114.503 27.7684 116.929 25.3419 116.929 22.3486V19.0676ZM116.926 56.0308C116.926 56.4058 116.841 56.6614 116.67 56.7978C116.534 56.9341 116.278 57.0023 115.903 57.0023H112.427C112.086 57.0023 111.847 56.9512 111.711 56.8489C111.574 56.7126 111.506 56.491 111.506 56.1842V30.6699C111.506 30.3972 111.557 30.2098 111.66 30.1075C111.762 29.9712 111.949 29.903 112.222 29.903H117.028L116.926 56.0308ZM132.183 34.3137C132.183 33.9728 132.336 33.8024 132.643 33.8024H138.779C139.256 33.8024 139.495 33.5979 139.495 33.1888V30.4789V29.9165H138.881H132.745C132.439 29.9165 132.285 29.7631 132.285 29.4563V21.531V20.713L131.621 20.7129H128.093C127.752 20.7129 127.547 20.9515 127.479 21.4288L126.865 29.4563C126.865 29.7631 126.729 29.9165 126.456 29.9165H122.366C121.957 29.9165 121.752 30.1039 121.752 30.4789V33.1888C121.752 33.5979 121.974 33.8024 122.417 33.8024H126.252C126.593 33.8024 126.763 34.0069 126.763 34.416V50.6244C126.763 52.806 127.309 54.4252 128.399 55.4819C129.49 56.5045 131.16 57.0158 133.41 57.0158C135.796 57.0158 137.535 56.9306 138.625 56.7601C139.137 56.6579 139.392 56.3681 139.392 55.8909V53.6923V53.0787H138.779H135.507C134.348 53.0787 133.495 52.806 132.95 52.2606C132.439 51.7152 132.183 50.7267 132.183 49.295V34.3137Z"></path>
<path d="M0.241243 33.2639H10.9742C15.0585 33.2639 18.9054 35.1835 21.3612 38.4471L31.9483 52.5165C32.1484 52.7824 32.1786 53.1393 32.026 53.435L25.9232 65.2592C25.6304 65.8265 24.8455 65.8932 24.4612 65.3835L0.241243 33.2639Z"></path>
<path d="M42.4727 33.2822H31.7398C27.6555 33.2822 23.8086 31.3626 21.3528 28.0991L10.7656 14.0297C10.5656 13.7638 10.5354 13.4068 10.688 13.1111L16.7908 1.28696C17.0836 0.719654 17.8684 0.652924 18.2528 1.16266L42.4727 33.2822Z"></path>
</svg>
</div>
<div className={styles.buttonContainer}></div>
</div>
<div className={styles.body}>{children} </div>
</div>
</main>
<footer className={styles.footer}>
<span>Powered by</span>
<a
href="https://blitzjs.com?utm_source=blitz-new&utm_medium=app-template&utm_campaign=blitz-new"
target="_blank"
rel="noopener noreferrer"
className={styles.textLink}
>
Blitz.js
</a>
</footer>
</div>
</BlitzProvider>
</body>
</html>
)
}

View File

@@ -1,47 +0,0 @@
import Link from "next/link"
import styles from "src/styles/Home.module.css"
import Test from "./react-query"
import {invoke, useAuthenticatedBlitzContext} from "../src/blitz-server"
import getCurrentUser from "../src/users/queries/getCurrentUser"
export default async function Home() {
await useAuthenticatedBlitzContext({
redirectTo: "/auth/login",
})
const user = await invoke(getCurrentUser, null)
console.log("user", user)
return (
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
width: "100%",
}}
>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexDirection: "column",
}}
>
<Link href={"/auth/signup"} className={styles.button}>
<strong>Sign Up</strong>
</Link>
<Link href={"/auth/login"} className={styles.loginButton}>
<strong>Login</strong>
</Link>
<div style={{height: 20}} />
<p>Server Session</p>
<p>UserId: {user?.id}</p>
<p>Email: {user?.email}</p>
<div style={{height: 20}} />
<p>Client Session</p>
<Test />
</div>
</div>
)
}

View File

@@ -1,34 +0,0 @@
"use client"
import {useQuery, useMutation} from "@blitzjs/rpc"
import logout from "../src/auth/mutations/logout"
import getCurrentUser from "../src/users/queries/getCurrentUser"
import {useTransition} from "react"
import {useRouter} from "next/navigation"
export default function Test() {
const router = useRouter()
const [user] = useQuery(getCurrentUser, null)
const [isPending, startTransition] = useTransition()
const [logoutMutation] = useMutation(logout)
console.log(user)
return (
<div>
<h1>Test</h1>
<p>{user?.email}</p>
<button
className="button small"
onClick={async () => {
await logoutMutation()
startTransition(() => {
// Refresh the current route and fetch new data from the server without
// losing client-side browser or React state.
router.refresh()
})
}}
>
Logout
</button>
</div>
)
}

View File

@@ -1,11 +0,0 @@
const {withBlitz} = require("@blitzjs/next")
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
serverComponentsExternalPackages: ["@prisma/client", "prisma"],
},
}
module.exports = withBlitz(nextConfig)

View File

@@ -1,38 +0,0 @@
{
"name": "next-blitz-auth",
"version": "0.1.1-beta.10",
"private": true,
"scripts": {
"blitz:dev": "next dev",
"blitz:build": "next build",
"blitz:start": "next start",
"lint": "next lint"
},
"dependencies": {
"@blitzjs/auth": "2.0.0-beta.34",
"@blitzjs/config": "2.0.0-beta.34",
"@blitzjs/next": "2.0.0-beta.34",
"@blitzjs/rpc": "2.0.0-beta.34",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "^4.5.0",
"@tanstack/react-query": "4.0.10",
"blitz": "2.0.0-beta.34",
"flatted": "3.2.7",
"next": "13.5.2",
"prisma": "^4.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "7.39.1",
"superjson": "1.11.0",
"zod": "3.20.2"
},
"devDependencies": {
"@types/node": "18.11.7",
"@types/react": "18.0.23",
"@types/react-dom": "18.0.7",
"eslint": "8.26.0",
"eslint-config-next": "13.0.0",
"typescript": "4.8.4"
}
}

Binary file not shown.

View File

@@ -1,5 +0,0 @@
import {PrismaClient} from "@prisma/client"
export * from "@prisma/client"
const db = new PrismaClient()
export default db

View File

@@ -1,47 +0,0 @@
-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"name" TEXT,
"email" TEXT NOT NULL,
"hashedPassword" TEXT,
"role" TEXT NOT NULL DEFAULT 'USER'
);
-- CreateTable
CREATE TABLE "Session" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"expiresAt" DATETIME,
"handle" TEXT NOT NULL,
"hashedSessionToken" TEXT,
"antiCSRFToken" TEXT,
"publicData" TEXT,
"privateData" TEXT,
"userId" INTEGER,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "Token" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"hashedToken" TEXT NOT NULL,
"type" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
"sentTo" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
CONSTRAINT "Token_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Session_handle_key" ON "Session"("handle");
-- CreateIndex
CREATE UNIQUE INDEX "Token_hashedToken_type_key" ON "Token"("hashedToken", "type");

View File

@@ -1,48 +0,0 @@
/*
Warnings:
- You are about to drop the `Token` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the column `createdAt` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `role` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `createdAt` on the `Session` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `Session` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX "Token_hashedToken_type_key";
-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "Token";
PRAGMA foreign_keys=on;
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT,
"email" TEXT NOT NULL,
"hashedPassword" TEXT
);
INSERT INTO "new_User" ("email", "hashedPassword", "id", "name") SELECT "email", "hashedPassword", "id", "name" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
CREATE TABLE "new_Session" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"expiresAt" DATETIME,
"handle" TEXT NOT NULL,
"hashedSessionToken" TEXT,
"antiCSRFToken" TEXT,
"publicData" TEXT,
"privateData" TEXT,
"userId" INTEGER,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Session" ("antiCSRFToken", "expiresAt", "handle", "hashedSessionToken", "id", "privateData", "publicData", "userId") SELECT "antiCSRFToken", "expiresAt", "handle", "hashedSessionToken", "id", "privateData", "publicData", "userId" FROM "Session";
DROP TABLE "Session";
ALTER TABLE "new_Session" RENAME TO "Session";
CREATE UNIQUE INDEX "Session_handle_key" ON "Session"("handle");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View File

@@ -1,3 +0,0 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"

View File

@@ -1,33 +0,0 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
name String?
email String @unique
hashedPassword String?
sessions Session[]
}
model Session {
id Int @id @default(autoincrement())
expiresAt DateTime?
handle String @unique
hashedSessionToken String?
antiCSRFToken String?
publicData String?
privateData String?
user User? @relation(fields: [userId], references: [id])
userId Int?
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1,4 +0,0 @@
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,61 +0,0 @@
import {AuthenticationError, PromiseReturnType} from "blitz"
import Link from "next/link"
import {LabeledTextField} from "../../core/components/LabeledTextField"
import {Form, FORM_ERROR} from "../../core/components/Form"
import login from "../../auth/mutations/login"
import {Login} from "../../auth/validations"
import {useMutation} from "@blitzjs/rpc"
import {startTransition} from "react"
import {useRouter} from "next/navigation"
type LoginFormProps = {
onSuccess?: (user: PromiseReturnType<typeof login>) => void
}
export const LoginForm = (props: LoginFormProps) => {
const [loginMutation] = useMutation(login)
const router = useRouter()
return (
<div>
<h1>Login</h1>
<Form
submitText="Login"
schema={Login}
initialValues={{email: "", password: ""}}
onSubmit={async (values) => {
try {
const user = await loginMutation(values)
props.onSuccess?.(user)
startTransition(() => {
// Refresh the current route and fetch new data from the server without
// losing client-side browser or React state.
router.refresh()
})
} catch (error: any) {
if (error instanceof AuthenticationError) {
return {[FORM_ERROR]: "Sorry, those credentials are invalid"}
} else {
return {
[FORM_ERROR]:
"Sorry, we had an unexpected error. Please try again. - " + error.toString(),
}
}
}
}}
>
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
<div>
<a>Forgot your password?</a>
</div>
</Form>
<div style={{marginTop: "1rem"}}>
Or <Link href={"/auth/signup"}>Sign Up</Link>
</div>
</div>
)
}
export default LoginForm

View File

@@ -1,51 +0,0 @@
import {LabeledTextField} from "../../core/components/LabeledTextField"
import {Form, FORM_ERROR} from "../../core/components/Form"
import signup from "../../auth/mutations/signup"
import {Signup} from "../../auth/validations"
import {useMutation} from "@blitzjs/rpc"
import {startTransition} from "react"
import {useRouter} from "next/navigation"
type SignupFormProps = {
onSuccess?: () => void
}
export const SignupForm = (props: SignupFormProps) => {
const [signupMutation] = useMutation(signup)
const router = useRouter()
return (
<div>
<h1>Create an Account</h1>
<Form
submitText="Create Account"
schema={Signup}
initialValues={{email: "", password: ""}}
onSubmit={async (values) => {
try {
await signupMutation(values)
props.onSuccess?.()
startTransition(() => {
// Refresh the current route and fetch new data from the server without
// losing client-side browser or React state.
router.refresh()
})
} catch (error: any) {
if (error.code === "P2002" && error.meta?.target?.includes("email")) {
// Error "P2002" comes from Prisma (https://www.prisma.io/docs/reference/api-reference/error-reference#p2002)
return {email: "This email is already being used"}
} else {
return {[FORM_ERROR]: error.toString()}
}
}
}}
>
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
</Form>
</div>
)
}
export default SignupForm

View File

@@ -1,26 +0,0 @@
import {NotFoundError} from "blitz"
import db from "../../../prisma"
// import {authenticateUser} from "./login"
import {ChangePassword} from "../validations"
import {resolver} from "@blitzjs/rpc"
// import {SecurePassword} from "@blitzjs/auth"
export default resolver.pipe(
//@ts-ignore
resolver.zod(ChangePassword),
resolver.authorize(),
async ({currentPassword, newPassword}, ctx) => {
const user = await db.user.findFirst({where: {id: ctx.session.userId}})
if (!user) throw new NotFoundError()
// await authenticateUser(user.email, currentPassword)
// const hashedPassword = await SecurePassword.hash(newPassword.trim())
await db.user.update({
where: {id: user.id},
data: {hashedPassword: newPassword},
})
return true
},
)

View File

@@ -1,64 +0,0 @@
import {vi, describe, it, beforeEach} from "vitest"
import db from "db"
import {hash256} from "@blitzjs/auth"
import forgotPassword from "./forgotPassword"
import previewEmail from "preview-email"
import {Ctx} from "@blitzjs/next"
beforeEach(async () => {
await db.$reset()
})
const generatedToken = "plain-token"
vi.mock("@blitzjs/auth", async () => {
const auth = await vi.importActual<Record<string, unknown>>("@blitzjs/auth")!
return {
...auth,
generateToken: () => generatedToken,
}
})
vi.mock("preview-email", () => ({default: vi.fn()}))
describe("forgotPassword mutation", () => {
it("does not throw error if user doesn't exist", async () => {
await expect(forgotPassword({email: "no-user@email.com"}, {} as Ctx)).resolves.not.toThrow()
})
it("works correctly", async () => {
// Create test user
const user = await db.user.create({
data: {
email: "user@example.com",
tokens: {
// Create old token to ensure it's deleted
create: {
type: "RESET_PASSWORD",
hashedToken: "token",
expiresAt: new Date(),
sentTo: "user@example.com",
},
},
},
include: {tokens: true},
})
// Invoke the mutation
await forgotPassword({email: user.email}, {} as Ctx)
const tokens = await db.token.findMany({where: {userId: user.id}})
const token = tokens[0]
if (!user.tokens[0]) throw new Error("Missing user token")
if (!token) throw new Error("Missing token")
// delete's existing tokens
expect(tokens.length).toBe(1)
expect(token.id).not.toBe(user.tokens[0].id)
expect(token.type).toBe("RESET_PASSWORD")
expect(token.sentTo).toBe(user.email)
expect(token.hashedToken).toBe(hash256(generatedToken))
expect(token.expiresAt > new Date()).toBe(true)
expect(previewEmail).toBeCalled()
})
})

View File

@@ -1,40 +0,0 @@
import {generateToken, hash256} from "@blitzjs/auth"
import {resolver} from "@blitzjs/rpc"
import db from "../../../prisma"
import {ForgotPassword} from "../validations"
const RESET_PASSWORD_TOKEN_EXPIRATION_IN_HOURS = 4
//@ts-ignore
export default resolver.pipe(resolver.zod(ForgotPassword), async ({email}) => {
// 1. Get the user
const user = await db.user.findFirst({where: {email: email.toLowerCase()}})
// 2. Generate the token and expiration date.
const token = generateToken()
const hashedToken = hash256(token)
const expiresAt = new Date()
expiresAt.setHours(expiresAt.getHours() + RESET_PASSWORD_TOKEN_EXPIRATION_IN_HOURS)
// 3. If user with this email was found
if (user) {
// 4. Delete any existing password reset tokens
await db.token.deleteMany({where: {type: "RESET_PASSWORD", userId: user.id}})
// 5. Save this new token in the database.
await db.token.create({
data: {
user: {connect: {id: user.id}},
type: "RESET_PASSWORD",
expiresAt,
hashedToken,
sentTo: user.email,
},
})
// 6. Send the email
} else {
// 7. If no user found wait the same time so attackers can't tell the difference
await new Promise((resolve) => setTimeout(resolve, 750))
}
// 8. Return the same result whether a password reset email was sent or not
return
})

View File

@@ -1,31 +0,0 @@
import {resolver} from "@blitzjs/rpc"
// import {AuthenticationError} from "blitz"
import db from "../../../prisma"
import {Login} from "../validations"
// export const authenticateUser = async (rawEmail: string, rawPassword: string) => {
// const {email, password} = Login.parse({email: rawEmail, password: rawPassword})
// const user = await db.user.findFirst({where: {email}})
// if (!user) throw new AuthenticationError()
// const result = await SecurePassword.verify(user.hashedPassword, password)
// if (result === SecurePassword.VALID_NEEDS_REHASH) {
// // Upgrade hashed password with a more secure hash
// const improvedHash = await SecurePassword.hash(password)
// await db.user.update({where: {id: user.id}, data: {hashedPassword: improvedHash}})
// }
// const {hashedPassword, ...rest} = user
// return rest
// }
//@ts-ignore
export default resolver.pipe(resolver.zod(Login), async ({email, password}, ctx) => {
// This throws an error if credentials are invalid
// const user = await authenticateUser(email, password)
const user = await db.user.findFirst({where: {email}})
//@ts-ignore
await ctx.session.$create({userId: user.id, role: user.role})
console.log("user", user)
return user
})

View File

@@ -1,5 +0,0 @@
import {Ctx} from "blitz"
export default async function logout(_: any, ctx: Ctx) {
return await ctx.session.$revoke()
}

View File

@@ -1,83 +0,0 @@
import {vi, describe, it, beforeEach, expect} from "vitest"
import resetPassword from "./resetPassword"
import db from "db"
import {SecurePassword, hash256} from "@blitzjs/auth"
beforeEach(async () => {
await db.$reset()
})
const mockCtx: any = {
session: {
$create: vi.fn(),
},
}
describe("resetPassword mutation", () => {
it("works correctly", async () => {
expect(true).toBe(true)
// Create test user
const goodToken = "randomPasswordResetToken"
const expiredToken = "expiredRandomPasswordResetToken"
const future = new Date()
future.setHours(future.getHours() + 4)
const past = new Date()
past.setHours(past.getHours() - 4)
const user = await db.user.create({
data: {
email: "user@example.com",
tokens: {
// Create old token to ensure it's deleted
create: [
{
type: "RESET_PASSWORD",
hashedToken: hash256(expiredToken),
expiresAt: past,
sentTo: "user@example.com",
},
{
type: "RESET_PASSWORD",
hashedToken: hash256(goodToken),
expiresAt: future,
sentTo: "user@example.com",
},
],
},
},
include: {tokens: true},
})
const newPassword = "newPassword"
// Non-existent token
await expect(
resetPassword({token: "no-token", password: "", passwordConfirmation: ""}, mockCtx),
).rejects.toThrowError()
// Expired token
await expect(
resetPassword(
{token: expiredToken, password: newPassword, passwordConfirmation: newPassword},
mockCtx,
),
).rejects.toThrowError()
// Good token
await resetPassword(
{token: goodToken, password: newPassword, passwordConfirmation: newPassword},
mockCtx,
)
// Delete's the token
const numberOfTokens = await db.token.count({where: {userId: user.id}})
expect(numberOfTokens).toBe(0)
// Updates user's password
const updatedUser = await db.user.findFirst({where: {id: user.id}})
expect(await SecurePassword.verify(updatedUser!.hashedPassword, newPassword)).toBe(
SecurePassword.VALID,
)
})
})

View File

@@ -1,50 +0,0 @@
import {hash256} from "@blitzjs/auth"
import db from "../../../prisma"
import {ResetPassword} from "../validations"
import login from "./login"
export class ResetPasswordError extends Error {
name = "ResetPasswordError"
message = "Reset password link is invalid or it has expired."
}
export default async function resetPassword(input: any, ctx: any) {
ResetPassword.parse(input)
// 1. Try to find this token in the database
const hashedToken = hash256(input.token)
const possibleToken = await db.token.findFirst({
where: {hashedToken, type: "RESET_PASSWORD"},
include: {user: true},
})
// 2. If token not found, error
if (!possibleToken) {
throw new ResetPasswordError()
}
const savedToken = possibleToken
// 3. Delete token so it can't be used again
await db.token.delete({where: {id: savedToken.id}})
// 4. If token has expired, error
if (savedToken.expiresAt < new Date()) {
throw new ResetPasswordError()
}
// 5. Since token is valid, now we can update the user's password
// const hashedPassword = await SecurePassword.hash(input.password.trim())
const user = await db.user.update({
where: {id: savedToken.userId},
data: {
hashedPassword: input.password,
},
})
// 6. Revoke all existing login sessions for this user
await db.session.deleteMany({where: {userId: user.id}})
// 7. Now log the user in with the new credentials
await login({email: user.email, password: input.password}, ctx)
return true
}

View File

@@ -1,19 +0,0 @@
import db from "../../../prisma"
// import {SecurePassword} from "@blitzjs/auth"
export default async function signup(input: {password: string; email: string}, ctx: any) {
const blitzContext = ctx
// const hashedPassword = await SecurePassword.hash((input.password as string) || "test-password")
const hashedPassword = (input.password as string) || "test-password"
const email = (input.email as string) || "test" + Math.random() + "@test.com"
const user = await db.user.create({
data: {email, hashedPassword},
})
await blitzContext.session.$create({
userId: user.id,
role: "user",
})
return {userId: blitzContext.session.userId, ...user, email: input.email}
}

View File

@@ -1,42 +0,0 @@
import {z} from "zod"
export const email = z
.string()
.email()
.transform((str) => str.toLowerCase().trim())
export const password = z
.string()
.min(10)
.max(100)
.transform((str) => str.trim())
export const Signup = z.object({
email,
password,
})
export const Login = z.object({
email,
password: z.string(),
})
export const ForgotPassword = z.object({
email,
})
export const ResetPassword = z
.object({
password: password,
passwordConfirmation: password,
token: z.string(),
})
.refine((data) => data.password === data.passwordConfirmation, {
message: "Passwords don't match",
path: ["passwordConfirmation"], // set the path of the error
})
export const ChangePassword = z.object({
currentPassword: z.string(),
newPassword: password,
})

View File

@@ -1,13 +0,0 @@
"use client"
import {AuthClientPlugin} from "@blitzjs/auth"
import {setupBlitzClient} from "@blitzjs/next"
import {BlitzRpcPlugin} from "@blitzjs/rpc"
export const {withBlitz, useSession, queryClient, BlitzProvider} = setupBlitzClient({
plugins: [
AuthClientPlugin({
cookiePrefix: "web-cookie-prefix",
}),
BlitzRpcPlugin({}),
],
})

View File

@@ -1,25 +0,0 @@
import type {BlitzCliConfig} from "blitz"
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import db from "../prisma"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import {BlitzLogger} from "blitz"
import {RpcServerPlugin} from "@blitzjs/rpc"
const {api, getBlitzContext, useAuthenticatedBlitzContext, invoke} = setupBlitzServer({
plugins: [
AuthServerPlugin({
cookiePrefix: "web-cookie-prefix",
storage: PrismaStorage(db),
isAuthorized: simpleRolesIsAuthorized,
}),
RpcServerPlugin({}),
],
logger: BlitzLogger({}),
})
export {api, getBlitzContext, useAuthenticatedBlitzContext, invoke}
export const cliConfig: BlitzCliConfig = {
customTemplates: "src/templates",
}

View File

@@ -1,83 +0,0 @@
import {useState, ReactNode, PropsWithoutRef} from "react"
import {FormProvider, useForm, UseFormProps} from "react-hook-form"
import {zodResolver} from "@hookform/resolvers/zod"
import {z} from "zod"
export interface FormProps<S extends z.ZodType<any, any>>
extends Omit<PropsWithoutRef<JSX.IntrinsicElements["form"]>, "onSubmit"> {
/** All your form fields */
children?: ReactNode
/** Text to display in the submit button */
submitText?: string
schema?: S
onSubmit: (values: z.infer<S>) => Promise<void | OnSubmitResult>
initialValues?: UseFormProps<z.infer<S>>["defaultValues"]
}
interface OnSubmitResult {
FORM_ERROR?: string
[prop: string]: any
}
export const FORM_ERROR = "FORM_ERROR"
export function Form<S extends z.ZodType<any, any>>({
children,
submitText,
schema,
initialValues,
onSubmit,
...props
}: FormProps<S>) {
const ctx = useForm<z.infer<S>>({
mode: "onBlur",
resolver: schema ? zodResolver(schema) : undefined,
defaultValues: initialValues,
})
const [formError, setFormError] = useState<string | null>(null)
return (
<FormProvider {...ctx}>
<form
onSubmit={ctx.handleSubmit(async (values) => {
const result = (await onSubmit(values)) || {}
for (const [key, value] of Object.entries(result)) {
if (key === FORM_ERROR) {
setFormError(value)
} else {
ctx.setError(key as any, {
type: "submit",
message: value,
})
}
}
})}
className="form"
{...props}
>
{/* Form fields supplied as children are rendered here */}
{children}
{formError && (
<div role="alert" style={{color: "red"}}>
{formError}
</div>
)}
{submitText && (
<button type="submit" disabled={ctx.formState.isSubmitting}>
{submitText}
</button>
)}
<style global jsx>{`
.form > * + * {
margin-top: 1rem;
}
`}</style>
</form>
</FormProvider>
)
}
export default Form

View File

@@ -1,63 +0,0 @@
import {forwardRef, PropsWithoutRef, ComponentPropsWithoutRef} from "react"
import {useFormContext} from "react-hook-form"
import {ErrorMessage} from "@hookform/error-message"
export interface LabeledTextFieldProps extends PropsWithoutRef<JSX.IntrinsicElements["input"]> {
/** Field name. */
name: string
/** Field label. */
label: string
/** Field type. Doesn't include radio buttons and checkboxes */
type?: "text" | "password" | "email" | "number"
outerProps?: PropsWithoutRef<JSX.IntrinsicElements["div"]>
labelProps?: ComponentPropsWithoutRef<"label">
}
export const LabeledTextField = forwardRef<HTMLInputElement, LabeledTextFieldProps>(
({label, outerProps, labelProps, name, ...props}, ref) => {
const {
register,
formState: {isSubmitting, errors},
} = useFormContext()
return (
<div {...outerProps}>
<label {...labelProps}>
{label}
<input disabled={isSubmitting} {...register(name)} {...props} />
</label>
<ErrorMessage
render={({message}) => (
<div role="alert" style={{color: "red"}}>
{message}
</div>
)}
errors={errors}
name={name}
/>
<style jsx>{`
label {
display: flex;
flex-direction: column;
align-items: start;
font-size: 1rem;
}
input {
font-size: 1rem;
padding: 0.25rem 0.5rem;
border-radius: 3px;
border: 1px solid purple;
appearance: none;
margin-top: 0.5rem;
}
`}</style>
</div>
)
},
)
LabeledTextField.displayName = "LabeledTextField"
export default LabeledTextField

View File

@@ -1,8 +0,0 @@
import {api} from "../../../blitz-server"
export default api((req, res, ctx) => {
// console.log("session", ctx.session)
//get cookie
console.dir("cookie", req.headers.cookie)
res.json({session: ctx.session.userId})
})

View File

@@ -1,4 +0,0 @@
import {rpcHandler} from "@blitzjs/rpc"
import {api} from "../../../blitz-server"
export default api(rpcHandler({onError: console.log}))

View File

@@ -1,303 +0,0 @@
.container {
display: flex;
flex-direction: column;
height: 100vh;
}
.main {
flex: 1;
padding: 0rem 1rem;
display: flex;
flex-direction: column;
}
.wrapper {
display: flex;
flex-direction: column;
gap: 2rem;
}
.frost {
background: rgba(255, 255, 255, 0.2);
border-radius: 16px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.31);
}
.header {
display: flex;
flex-direction: column;
padding: 4rem 0rem 2rem 0rem;
text-align: center;
gap: 2rem;
}
.header h1 {
max-width: 620px;
align-self: center;
}
.body {
composes: frost;
border-radius: var(--border-radius);
display: flex;
padding: 1rem;
width: 100%;
flex-direction: row;
align-self: center;
max-width: var(--screen-width);
}
.instructions {
display: inline-flex;
flex-direction: column;
padding: 1rem;
width: 100%;
}
.globe {
position: fixed;
width: 350vmin;
height: 75vmin;
left: 20%;
top: 50%;
transform: translate(-50%, calc(-50% + 40px));
z-index: -1;
border-radius: 100%;
background-image: radial-gradient(
95.63% 95.63% at 95.92% 0%,
rgba(255, 255, 255, 0.62) 0%,
#8155ff38 60.42%,
#002fff5c 169%
);
filter: blur(8vmin);
}
.footer {
display: flex;
padding: 2rem 0;
justify-content: center;
align-items: center;
}
.footer span {
margin-right: 0.2rem;
}
.code {
display: flex;
align-items: center;
gap: 0.5rem;
}
.code span {
background: rgba(124, 58, 237, 50%);
border-radius: 50rem;
font-size: 14px;
font-weight: 500;
padding: 17px;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
color: rgb(57, 33, 97);
}
.code pre {
background: rgba(124, 58, 237, 12%);
border-radius: 4px;
padding: 0.7em 1.4em;
text-align: center;
}
.code code {
font-size: 0.86em;
font-weight: bold;
color: rgb(124, 58, 237);
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}
.toastContainer {
border: 1px solid #edff;
padding: 0 1rem;
background: #eeff;
color: #62af;
text-align: center;
}
.toastContainer strong {
color: rgb(124, 58, 237);
}
.textLink {
color: rgb(124, 58, 237);
background: linear-gradient(to right, rgba(231, 216, 246, 1), rgba(231, 216, 246, 1)),
linear-gradient(to right, rgba(99, 1, 235, 1), rgba(124, 58, 237, 1), rgba(231, 216, 246, 1));
background-size: 100% 1px, 0 1px;
background-position: 100% 100%, 0 100%;
background-repeat: no-repeat;
transition: background-size 400ms;
}
.textLink:hover,
.textLink:focus,
.textLink:active {
background-size: 0 1px, 100% 1px;
}
.arrowIcon {
box-sizing: border-box;
display: block;
width: 8px;
height: 8px;
border-top: 2px solid;
transform: scale(var(--ggs, 1));
border-right: 2px solid;
position: absolute;
right: 6px;
top: 6px;
color: #b1a5c4;
}
.arrowIcon::after {
content: "";
display: block;
box-sizing: border-box;
position: absolute;
width: 8px;
height: 2px;
background: currentColor;
transform: rotate(-45deg);
top: 2px;
right: -1px;
}
.buttonContainer {
display: flex;
flex-direction: row;
gap: 1rem;
justify-content: center;
align-items: center;
flex: 1;
}
.button {
background: linear-gradient(to top, rgb(124, 58, 237), rgb(117, 81, 236));
border: 1px solid rgb(231, 216, 246);
color: white;
text-shadow: rgba(0, 0, 0, 0.25) 0px 3px 8px;
padding: 0 24px;
height: 48px;
width: 200px;
max-width: 300px;
position: relative;
display: inline-flex;
justify-content: center;
align-items: center;
flex-shrink: 0;
user-select: none;
white-space: nowrap;
border-radius: 0.75rem;
border-bottom-left-radius: 0px;
font-size: 15px;
transition: all 0.3s ease 0s;
cursor: pointer;
}
.button:hover {
color: white;
text-shadow: rgb(0 0 0 / 56%) 0px 3px 12px;
box-shadow: rgb(80 63 205 / 50%) 0px 1px 40px;
}
.loginButton {
composes: button;
background: rgb(248 250 252);
border: 1px solid rgb(231, 216, 246);
color: rgb(30 41 59);
text-shadow: none;
}
.loginButton:hover {
color: rgb(30 41 59);
text-shadow: none;
}
.card:hover .arrowIcon {
color: #7450ec;
}
.linkGrid {
display: flex;
flex-direction: column;
flex-wrap: wrap;
gap: 1rem;
}
.card {
composes: frost;
padding: 1rem 0rem;
text-align: center;
color: inherit;
text-decoration: none;
border-radius: 10px;
border-bottom-left-radius: 0px;
transition: color 0.15s ease, border-color 0.15s ease;
max-width: 200px;
min-width: 200px;
display: flex;
flex-direction: row;
justify-content: center;
}
.card:hover,
.card:focus,
.card:active {
color: #7450ec;
border-color: #7450ec;
}
.card h2 {
margin: 0 0 1rem 0;
font-size: 1.5rem;
}
.card p {
margin: 0;
font-size: 1.25rem;
line-height: 1.5;
}
.logo {
flex: 1;
padding: 1rem 2rem;
}
.logo svg {
height: 100%;
width: 200px;
fill: #7450ec;
}
/* MOBILE */
@media (max-width: 800px) {
.linkGrid {
width: 100%;
}
.card {
max-width: 100%;
}
.body {
flex-wrap: wrap;
}
.buttonContainer {
flex-wrap: wrap;
}
}

View File

@@ -1,25 +0,0 @@
:root {
--border-radius: 0.75rem;
--screen-width: 90vmin;
}
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell,
Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
a {
color: inherit;
text-decoration: none;
}
i {
font-size: 0.8rem;
}
* {
box-sizing: border-box;
}

View File

@@ -1,7 +0,0 @@
import {useQuery} from "@blitzjs/rpc"
import getCurrentUser from "../../../src/users/queries/getCurrentUser"
export const useCurrentUser = () => {
const [user] = useQuery(getCurrentUser, null)
return user
}

View File

@@ -1,16 +0,0 @@
import {Ctx} from "blitz"
import db from "../../../prisma"
export default async function getCurrentUser(input: null, ctx: Ctx) {
if (!ctx.session.userId) return null
const user = await db.user.findFirst({
where: {id: ctx.session.userId},
select: {id: true, name: true, email: true},
})
return user
}
export const config = {
httpMethod: "GET",
}

View File

@@ -1,12 +0,0 @@
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
import {User} from "./prisma"
declare module "@blitzjs/auth" {
export interface Session {
isAuthorized: SimpleRolesIsAuthorized
PublicData: {
userId: User["id"]
email: User["email"]
}
}
}

View File

@@ -23,15 +23,15 @@
]
},
"dependencies": {
"@blitzjs/auth": "2.0.0-beta.34",
"@blitzjs/config": "2.0.0-beta.34",
"@blitzjs/next": "2.0.0-beta.34",
"@blitzjs/rpc": "2.0.0-beta.34",
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "2.0.0-beta.34",
"next": "13.5.2",
"blitz": "workspace:2.0.0-beta.23",
"next": "12.2.5",
"openid-client": "5.2.1",
"prisma": "4.6.1",
"react": "18.2.0",

View File

@@ -40,12 +40,17 @@ export const LoginForm = (props: LoginFormProps) => {
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
<div>
<Link href={Routes.ForgotPasswordPage()}>Forgot your password?</Link>
<Link href={Routes.ForgotPasswordPage()}>
Forgot your password?
</Link>
</div>
</Form>
<div style={{ marginTop: "1rem" }}>
Or <Link href={Routes.SignupPage()}>Sign Up</Link>
Or{" "}
<Link href={Routes.SignupPage()}>
Sign Up
</Link>
</div>
</div>
)

View File

@@ -3,7 +3,7 @@ import db from "db"
import { authenticateUser } from "./login"
import { ChangePassword } from "../validations"
import { resolver } from "@blitzjs/rpc"
import { SecurePassword } from "@blitzjs/auth/secure-password"
import { SecurePassword } from "@blitzjs/auth"
export default resolver.pipe(
resolver.zod(ChangePassword),

View File

@@ -1,4 +1,4 @@
import { SecurePassword } from "@blitzjs/auth/secure-password"
import { SecurePassword } from "@blitzjs/auth"
import { resolver } from "@blitzjs/rpc"
import { AuthenticationError } from "blitz"
import db from "db"

View File

@@ -1,7 +1,6 @@
import { hash256 } from "@blitzjs/auth"
import { SecurePassword, hash256 } from "@blitzjs/auth"
import db from "db"
import { ResetPassword } from "../validations"
import { SecurePassword } from "@blitzjs/auth/secure-password"
import login from "./login"
export class ResetPasswordError extends Error {

View File

@@ -1,5 +1,5 @@
import db from "db"
import { SecurePassword } from "@blitzjs/auth/secure-password"
import { SecurePassword } from "@blitzjs/auth"
import { Role } from "types"
export default async function signup(input, ctx) {

View File

@@ -38,7 +38,7 @@ const UserInfo = () => {
} else {
return (
<>
<Link href={Routes.SignupPage()} className="button small">
<Link href={Routes.SignupPage()}className="button small">
<strong>Sign Up</strong>
</Link>
<Link href={Routes.LoginPage()} className="button small">
@@ -55,7 +55,7 @@ const Home: BlitzPage = () => {
<div className="container">
<main>
<div className="logo">
<Image src={`${logo.src}`} alt="blitzjs" width={256} height={118} layout="fixed" />
<Image src={`${logo.src}`} alt="blitzjs" width="256px" height="118px" layout="fixed" />
</div>
<p>
<strong>Congrats!</strong> Your app is ready, including user sign-up and log-in.

View File

@@ -1,14 +1,15 @@
const { withNextAuthAdapter } = require("@blitzjs/auth")
// @ts-check
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})
const { withBlitz } = require("@blitzjs/next")
/**
* @type {import('next').NextConfig}
* @type {import('@blitzjs/next').BlitzConfig}
**/
const config = {
reactStrictMode: true,
blitz: {
resolversDynamicImport: true,
},
}
module.exports = withBlitz(withNextAuthAdapter(config))
module.exports = withBlitz(withBundleAnalyzer(config))

View File

@@ -24,16 +24,15 @@
]
},
"dependencies": {
"@blitzjs/auth": "2.0.0-beta.34",
"@blitzjs/config": "2.0.0-beta.34",
"@blitzjs/next": "2.0.0-beta.34",
"@blitzjs/rpc": "2.0.0-beta.34",
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@blitzjs/rpc": "workspace:*",
"@hookform/error-message": "2.0.0",
"@hookform/resolvers": "2.9.10",
"@prisma/client": "4.6.1",
"blitz": "2.0.0-beta.34",
"next": "13.5.2",
"next-auth": "4.18.7",
"blitz": "workspace:2.0.0-beta.23",
"next": "12.2.5",
"prisma": "4.6.1",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -40,12 +40,17 @@ export const LoginForm = (props: LoginFormProps) => {
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
<div>
<Link href={Routes.ForgotPasswordPage()}>Forgot your password?</Link>
<Link href={Routes.ForgotPasswordPage()}>
Forgot your password?
</Link>
</div>
</Form>
<div style={{ marginTop: "1rem" }}>
Or <Link href={Routes.SignupPage()}>Sign Up</Link>
Or{" "}
<Link href={Routes.SignupPage()}>
Sign Up
</Link>
</div>
</div>
)

View File

@@ -10,7 +10,6 @@ type SignupFormProps = {
export const SignupForm = (props: SignupFormProps) => {
const [signupMutation] = useMutation(signup)
return (
<div>
<h1>Create an Account</h1>

View File

@@ -3,7 +3,7 @@ import db from "db"
import { authenticateUser } from "./login"
import { ChangePassword } from "../validations"
import { resolver } from "@blitzjs/rpc"
import { SecurePassword } from "@blitzjs/auth/secure-password"
import { SecurePassword } from "@blitzjs/auth"
export default resolver.pipe(
resolver.zod(ChangePassword),

Some files were not shown because too many files have changed in this diff Show More