Compare commits
97 Commits
@nhost/cor
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b60cd0411b | ||
|
|
503339e5a8 | ||
|
|
6d031e7484 | ||
|
|
e80c7b629a | ||
|
|
7a469e1e1e | ||
|
|
9b28e1329a | ||
|
|
4b572c4f58 | ||
|
|
df29c8f98d | ||
|
|
a08c3ec2d1 | ||
|
|
fef034aa6e | ||
|
|
7037af8ae6 | ||
|
|
477b48f184 | ||
|
|
33ac09fa40 | ||
|
|
92d66b9413 | ||
|
|
9eb9b590f9 | ||
|
|
7edca99d48 | ||
|
|
964cc6ded3 | ||
|
|
a69e0032bf | ||
|
|
86fbf934d6 | ||
|
|
0d6ecd8397 | ||
|
|
56b57b2878 | ||
|
|
e79ee93fde | ||
|
|
7cec42b392 | ||
|
|
f254c329f5 | ||
|
|
2a84a025d5 | ||
|
|
c2b0625c31 | ||
|
|
e80384c7ee | ||
|
|
8fa4813b4e | ||
|
|
d4c2e9eb78 | ||
|
|
557d1a69b3 | ||
|
|
4b811d939e | ||
|
|
f2a25b688d | ||
|
|
e9c82d8609 | ||
|
|
853527a770 | ||
|
|
9e6e05c1b2 | ||
|
|
85b5d89dbd | ||
|
|
d22885f6b7 | ||
|
|
5944b25e7e | ||
|
|
52fc5d3123 | ||
|
|
7e0608f5ca | ||
|
|
8876819687 | ||
|
|
635d82b18f | ||
|
|
6a1def9b86 | ||
|
|
2cc075f4ef | ||
|
|
bbe6750632 | ||
|
|
19149261aa | ||
|
|
8b2d1b00a1 | ||
|
|
3231e31c3e | ||
|
|
be1ef6fe79 | ||
|
|
5a963832e2 | ||
|
|
aa3f5c243c | ||
|
|
5dce0f0fdc | ||
|
|
3c0e9fbb84 | ||
|
|
6c202304b2 | ||
|
|
50dcf41e6c | ||
|
|
d6b4f83e16 | ||
|
|
ba86ae229d | ||
|
|
96f41ad0de | ||
|
|
aba0c8b2da | ||
|
|
a27eeeab8e | ||
|
|
61a746e674 | ||
|
|
7f37c87929 | ||
|
|
3322c4b795 | ||
|
|
1e70c7e7a5 | ||
|
|
9fbbdca60d | ||
|
|
d843f1a3ed | ||
|
|
464a10fa06 | ||
|
|
2cb1c36c76 | ||
|
|
b4670024ca | ||
|
|
feb616ecc0 | ||
|
|
7bc6d231b8 | ||
|
|
84e72f1d8d | ||
|
|
05ced50d74 | ||
|
|
4c916a94f0 | ||
|
|
a69a6d63e3 | ||
|
|
5abb2dda3f | ||
|
|
5630c07a8a | ||
|
|
5c6239589c | ||
|
|
9772a3b577 | ||
|
|
5b69e6eccb | ||
|
|
1ca5d34c80 | ||
|
|
c161339423 | ||
|
|
ab469fba84 | ||
|
|
b122a306a4 | ||
|
|
d3a2eae789 | ||
|
|
3ac1694d1e | ||
|
|
032743c750 | ||
|
|
5029c0b934 | ||
|
|
7eb927b549 | ||
|
|
dbb29ac4d6 | ||
|
|
0348114d26 | ||
|
|
e66c1689a4 | ||
|
|
80c1de6a55 | ||
|
|
52de584034 | ||
|
|
edfb04cd07 | ||
|
|
bb30d683ee | ||
|
|
3b16cfd295 |
17
.github/actions/install-dependencies/action.yaml
vendored
Normal file
17
.github/actions/install-dependencies/action.yaml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: Install Node and package dependencies
|
||||
description: 'Install Node dependencies with pnpm'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v2.2.1
|
||||
with:
|
||||
version: 6.32.14
|
||||
- name: Use Node.js 16
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
cache: 'pnpm'
|
||||
# * Install package dependencies. As cache is enabled, it will cache/restore downloaded files
|
||||
- shell: bash
|
||||
name: Install packages
|
||||
run: pnpm install --frozen-lockfile
|
||||
127
.github/workflows/tests.yaml
vendored
127
.github/workflows/tests.yaml
vendored
@@ -1,8 +1,4 @@
|
||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||
# Poached from https://github.com/hayes/pothos/tree/main/.github/workflows, thanks to the original author
|
||||
|
||||
name: Node.js CI
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -10,61 +6,106 @@ on:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'templates/**'
|
||||
- 'examples/**'
|
||||
- 'assets/**'
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
types: [opened, synchronize]
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'templates/**'
|
||||
- 'examples/**'
|
||||
- 'assets/**'
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: nhost
|
||||
jobs:
|
||||
build:
|
||||
name: Build @nhost packages
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14, 16]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install nhost CLI
|
||||
run: curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | bash
|
||||
|
||||
- name: Start Nhost Backend
|
||||
# * Install Node and dependencies. Package downloads will be cached for the next jobs.
|
||||
- name: Install Node and dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
# * Build all Nhost packages as they are all supposed to be tested.
|
||||
# * They will be reused through the Turborepo cache
|
||||
- name: Build packages
|
||||
run: pnpm build
|
||||
# * List packagesthat has an `e2e` script, except the root, and return an array of their name and path
|
||||
- name: List examples with an e2e script
|
||||
id: set-matrix
|
||||
run: |
|
||||
cp -R examples/testing-project /tmp/
|
||||
cd /tmp/testing-project
|
||||
nhost dev &
|
||||
|
||||
- uses: pnpm/action-setup@v2.2.1
|
||||
PACKAGES=$(pnpm recursive list --depth -1 --parseable --filter=!nhost-root \
|
||||
| xargs -I@ jq "if (.scripts.e2e | length) != 0 then {name: .name, path: \"@\"} else null end" @/package.json \
|
||||
| awk "!/null/" \
|
||||
| jq -c --slurp)
|
||||
echo "::set-output name=matrix::$PACKAGES"
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
e2e:
|
||||
name: 'e2e: ${{ matrix.package.name }}'
|
||||
needs: build
|
||||
strategy:
|
||||
# * Don't cancel other matrices when one fails
|
||||
fail-fast: false
|
||||
matrix:
|
||||
package: ${{ fromJson(needs.build.outputs.matrix) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# * Install Nhost CLI if a `nhost/config.yaml` file is found
|
||||
- name: Install Nhost CLI
|
||||
if: hashFiles(format('{0}/nhost/config.yaml', matrix.package.path)) != ''
|
||||
run: curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | bash
|
||||
# * Install Node and dependencies. Package dependencies won't be downloaded again as they have been cached by the `build` job.
|
||||
- name: Install Node and dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
# * Run the `ci` script of the current package of the matrix. Dependencies build is cached by Turborepo
|
||||
- name: Run e2e test
|
||||
run: pnpm run e2e -- --filter="${{ matrix.package.name }}"
|
||||
# * Run this step only if the previous step failed, and some Cypress screenshots/videos exist
|
||||
- name: Upload Cypress videos and screenshots
|
||||
if: ${{ failure() && hashFiles(format('{0}/cypress/screenshots/**', matrix.package.path), format('{0}/cypress/videos/**', matrix.package.path)) != ''}}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
version: 6.32.3
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
name: cypress-${{ matrix.package.name }}
|
||||
path: |
|
||||
${{format('{0}/cypress/screenshots/**', matrix.package.path)}}
|
||||
${{format('{0}/cypress/videos/**', matrix.package.path)}}
|
||||
unit:
|
||||
name: Unit tests
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# * Install Node and dependencies. Package dependencies won't be downloaded again as they have been cached by the `build` job.
|
||||
- name: Install Node and dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
# * Run every `test` script in the workspace . Dependencies build is cached by Turborepo
|
||||
- name: Run unit tests
|
||||
run: pnpm run test
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Cache turbo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ./node_modules/.cache/turbo
|
||||
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
turbo-${{ github.job }}-${{ github.ref_name }}-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Wait for Nhost
|
||||
run: pnpm run wait
|
||||
|
||||
- name: Build, tests and lint
|
||||
run: pnpm run ci
|
||||
files: '**/coverage/coverage-final.json'
|
||||
name: codecov-umbrella
|
||||
- name: Create summary
|
||||
run: |
|
||||
echo '### Code coverage' >> $GITHUB_STEP_SUMMARY
|
||||
echo 'Visit [codecov](https://app.codecov.io/gh/nhost/nhost/) to see the code coverage reports' >> $GITHUB_STEP_SUMMARY
|
||||
lint:
|
||||
name: Lint
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
# * Install Node and dependencies. Package dependencies won't be downloaded again as they have been cached by the `build` job.
|
||||
- name: Install Node and dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
# * Run every `lint` script in the workspace . Dependencies build is cached by Turborepo
|
||||
- name: Lint
|
||||
run: pnpm run lint
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -53,4 +53,7 @@ todo.md
|
||||
|
||||
# TypeDoc output
|
||||
|
||||
.docgen
|
||||
.docgen
|
||||
|
||||
# Nhost CLI data
|
||||
.nhost
|
||||
|
||||
@@ -60,19 +60,24 @@ $ pnpm start
|
||||
|
||||
## Run test suites
|
||||
|
||||
In order to run tests, the Nhost testing backend should be running locally. You can run it from a separate terminal:
|
||||
### Unit tests
|
||||
|
||||
```sh
|
||||
$ cd examples/testing-project
|
||||
$ nhost -d
|
||||
```
|
||||
|
||||
Once Nhost is started locally, you can run the tests with the following command from the repository root:
|
||||
You can run the unit tests with the following command from the repository root:
|
||||
|
||||
```sh
|
||||
$ pnpm test
|
||||
```
|
||||
|
||||
### End-to-end tests
|
||||
|
||||
Each package that defines end-to-end tests embeds their own Nhost configuration, that will be automatically when running the tests. As a result, you must make sure you are not running the Nhost CLI before running the tests.
|
||||
|
||||
You can run the e2e tests with the following command from the repository root:
|
||||
|
||||
```sh
|
||||
$ pnpm e2e
|
||||
```
|
||||
|
||||
## Changesets
|
||||
|
||||
If you've made changes to the packages, you must describe those changes so that they can be reflected in the next release.
|
||||
|
||||
26
README.md
26
README.md
@@ -192,6 +192,13 @@ Here are some ways of contributing to making Nhost better:
|
||||
<sub><b>Mrinal Wahal</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/timpratim">
|
||||
<img src="https://avatars.githubusercontent.com/u/32492961?v=4" width="100;" alt="timpratim"/>
|
||||
<br />
|
||||
<sub><b>Pratim</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/FuzzyReason">
|
||||
<img src="https://avatars.githubusercontent.com/u/62517920?v=4" width="100;" alt="FuzzyReason"/>
|
||||
@@ -205,15 +212,15 @@ Here are some ways of contributing to making Nhost better:
|
||||
<br />
|
||||
<sub><b>Macmac49</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/subhendukundu">
|
||||
<img src="https://avatars.githubusercontent.com/u/20059141?v=4" width="100;" alt="subhendukundu"/>
|
||||
<br />
|
||||
<sub><b>Subhendu Kundu</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/heygambo">
|
||||
<img src="https://avatars.githubusercontent.com/u/449438?v=4" width="100;" alt="heygambo"/>
|
||||
@@ -248,15 +255,15 @@ Here are some ways of contributing to making Nhost better:
|
||||
<br />
|
||||
<sub><b>Gavan Wilhite</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/jerryjappinen">
|
||||
<img src="https://avatars.githubusercontent.com/u/1101002?v=4" width="100;" alt="jerryjappinen"/>
|
||||
<br />
|
||||
<sub><b>Jerry Jäppinen</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/mustafa-hanif">
|
||||
<img src="https://avatars.githubusercontent.com/u/30019262?v=4" width="100;" alt="mustafa-hanif"/>
|
||||
@@ -271,13 +278,6 @@ Here are some ways of contributing to making Nhost better:
|
||||
<sub><b>Nicolas Bourdin</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/timpratim">
|
||||
<img src="https://avatars.githubusercontent.com/u/32492961?v=4" width="100;" alt="timpratim"/>
|
||||
<br />
|
||||
<sub><b>Pratim</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Savinvadim1312">
|
||||
<img src="https://avatars.githubusercontent.com/u/16936043?v=4" width="100;" alt="Savinvadim1312"/>
|
||||
|
||||
@@ -60,5 +60,13 @@ module.exports = {
|
||||
allowAnonymousFunction: true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.test.js', '*.spec.js', '*.test.ts', '*.spec.ts', '*.cy.js', '*.cy.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-expressions': 'off'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -34,7 +34,11 @@ export default defineConfig({
|
||||
include: [`${PWD}/src/**/*.{spec,test}.{ts,tsx}`, `${PWD}/tests/**/*.{spec,test}.{ts,tsx}`],
|
||||
// Note: temporarily disabled threads, because of a bug in vitest
|
||||
// https://github.com/vitest-dev/vitest/issues/1171
|
||||
threads: false
|
||||
threads: false,
|
||||
coverage: {
|
||||
enabled: process.env.CI === 'true',
|
||||
reporter: ['json']
|
||||
}
|
||||
},
|
||||
build: {
|
||||
sourcemap: true,
|
||||
|
||||
@@ -22,7 +22,7 @@ await nhost.auth.signUp({
|
||||
})
|
||||
```
|
||||
|
||||
If you've turned on email verification in your app's **login settings**, a user will be sent a verification email upon signup. The user must click the verification link in the email before they can sign in.
|
||||
If you've turned on email verification in your app's **Authentication Settings**, a user will be sent a verification email upon signup. The user must click the verification link in the email before they can sign in.
|
||||
|
||||
## Sign In
|
||||
|
||||
@@ -39,6 +39,6 @@ await nhost.auth.signIn({
|
||||
|
||||
## Verified Emails
|
||||
|
||||
You can decide if only verified emails should be able to sign in or not. Modify the **Only allow login for verified emails.** setting in the **Login Settings** section under **Users** in your Nhost app.
|
||||
You can decide if only verified emails should be able to sign in or not. Modify the **Only allow login for verified emails.** setting in the **Authentication Settings** section under **Users** in your Nhost app.
|
||||
|
||||
An email-verification email is automatically sent to the user during sign-up if your app only allows to sign in users with verified emails. You can also manually send the verification email to the user using [`nhost.auth.sendVerificationEmail()`](/reference/javascript/auth/send-verification-email).
|
||||
|
||||
@@ -11,7 +11,7 @@ The Magic Link sign-in method enables you to sign in users to your app using an
|
||||
|
||||
## Setup
|
||||
|
||||
Enable the Magic Link sign-in method in the Nhost dashboard under **Users** -> **Login settings** -> **Magic Link**.
|
||||
Enable the Magic Link sign-in method in the Nhost dashboard under **Users** -> **Authentication Settings** -> **Magic Link**.
|
||||
|
||||

|
||||
|
||||
@@ -30,4 +30,4 @@ nhost.auth.signIn({
|
||||
})
|
||||
```
|
||||
|
||||
If you want to change the email for your magic link emails, you can do so by changing the [email templates](/platform/authentication/email-templates).
|
||||
If you want to change the email for your magic link emails, you can do so by changing the [email templates](/platform/authentication/email-templates).
|
||||
|
||||
@@ -11,7 +11,7 @@ Follow this guide to sign in users with a phone number (SMS).
|
||||
|
||||
You need a [Twilio account](https://www.twilio.com/try-twilio) to use this feature because all SMS are sent through Twilio.
|
||||
|
||||
Enable the Phone Number (SMS) sign-in method in the Nhost dashboard under **Users** -> **Login settings** -> **Passwordless SMS**.
|
||||
Enable the Phone Number (SMS) sign-in method in the Nhost dashboard under **Users** -> **Authentication Settings** -> **Passwordless SMS**.
|
||||
|
||||
You need to insert the following settings in the Nhost dashboard from Twilio:
|
||||
|
||||
@@ -19,11 +19,10 @@ You need to insert the following settings in the Nhost dashboard from Twilio:
|
||||
- Auth Token
|
||||
- Messaging Service SID (or a Twilio phone number)
|
||||
|
||||
<video width="99%" autoPlay muted loop controls="true" style={{marginBottom: '15px'}}>
|
||||
<video width="99%" autoPlay muted loop controls="true" style={{ marginBottom: '15px' }}>
|
||||
<source src="/videos/enable-sms-sign-in.mp4" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
|
||||
## Sign In
|
||||
|
||||
To sign in users with a phone number is a two-step process:
|
||||
@@ -53,7 +52,6 @@ Phone numbers should start with `+` (not `00`) to follow the [E.164 formatting s
|
||||
|
||||
:::
|
||||
|
||||
|
||||
## Other SMS Providers
|
||||
|
||||
We only support Twilio for now. If you want support for another SMS provider, please create an issue on [GitHub](https://github.com/nhost/nhost).
|
||||
We only support Twilio for now. If you want support for another SMS provider, please create an issue on [GitHub](https://github.com/nhost/nhost).
|
||||
|
||||
@@ -17,7 +17,7 @@ Nhost Authentication support the following sign-in methods:
|
||||
|
||||
## Enabling Social Sign-In Provider
|
||||
|
||||
To start with social sign-in, select your app in Nhost Console and go to **Users** → **Login settings**.
|
||||
To start with social sign-in, select your app in Nhost Console and go to **Users** → **Authentication Settings**.
|
||||
|
||||
You need to set the Client ID and Client Secret for each provider that you want to enable.
|
||||
|
||||
@@ -33,7 +33,7 @@ nhost.auth.signIn({
|
||||
})
|
||||
```
|
||||
|
||||
Users are redirected to your Nhost app's **client URL** by default. By default, your Nhost app's client URL is set to `http://localhost:3000`. You can change the value of your client URL in the Nhost console by going to **Users** → **Login settings** → **Client URL**.
|
||||
Users are redirected to your Nhost app's **client URL** by default. By default, your Nhost app's client URL is set to `http://localhost:3000`. You can change the value of your client URL in the Nhost console by going to **Users** → **Authentication Settings** → **Client URL**.
|
||||
|
||||
## Provider OAuth scopes
|
||||
|
||||
|
||||
@@ -41,6 +41,12 @@ The following dependencies are required:
|
||||
- [Git](https://git-scm.com/downloads)
|
||||
- [Docker](https://www.docker.com/get-started) (must be running while using the CLI)
|
||||
|
||||
:::info
|
||||
|
||||
Make sure you have the correct permissions for Docker so you don't have to run Docker with `sudo`. See ["Post-installation steps for Linux"](https://docs.docker.com/engine/install/linux-postinstall/) from Docker's documentation.
|
||||
|
||||
:::
|
||||
|
||||
## Get started
|
||||
|
||||
Start by authenticating yourself to Nhost Cloud:
|
||||
@@ -75,6 +81,18 @@ nhost up
|
||||
|
||||
Hasura Console starts automatically and your Nhost app is running locally with the backend URL: `http://localhost:1337`.
|
||||
|
||||
## Emails
|
||||
|
||||
During local development with the CLI, all transactional emails from Authentication are sent to a local Mailhog instance, instead of to the recipient's email address. You'll see an address where after starting [`nhost up`](/reference/cli/up) where all emails are sent to.
|
||||
|
||||
For the example below, all emails are accessable at `http://localhost:8839`.
|
||||
|
||||
```bash
|
||||
$ nhost up
|
||||
✔ Your app is running at http://localhost:1337 (Ctrl+C to stop)
|
||||
ℹ Emails will be sent to http://localhost:8839
|
||||
```
|
||||
|
||||
## What's next?
|
||||
|
||||
- Read our in-depth guide on [Get started with Nhost CLI](/platform/overview/get-started-with-nhost-cli)
|
||||
|
||||
@@ -18,7 +18,7 @@ Event Triggers can also be triggered manually in the Hasura Console.
|
||||
|
||||
Let's say you're building an e-commerce application and you want to send an email to the customer when a new order is placed. Orders are stored in the `orders` table in your database.
|
||||
|
||||
To send out an email every time a new order is placed, you create an event trigger that listens for the `INSERT` event on the `orders` table. Now every time an order is placed, the even trigger invokes a webhook with the order information, and the webhook sends out the email.
|
||||
To send out an email every time a new order is placed, you create an event trigger that listens for the `INSERT` event on the `orders` table. Now every time an order is placed, the event trigger invokes a webhook with the order information, and the webhook sends out the email.
|
||||
|
||||
## Create Event Trigger
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ It's currently not possible to connect directly to the Postgres database via a c
|
||||
|
||||
:::
|
||||
|
||||
The database is managed via the Hasura Console where you can manage the database via an intuative UI. You can also use SQL to directly interact with the database via the Hasura Console.
|
||||
The database is managed via the Hasura Console where you can manage the database via an intuitive UI. You can also use SQL to directly interact with the database via the Hasura Console.
|
||||
|
||||
## Hasura Console
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ title: signOut()
|
||||
sidebar_label: signOut()
|
||||
slug: /reference/javascript/auth/sign-out
|
||||
description: Use `nhost.auth.signOut` to sign out the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L256
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L222
|
||||
---
|
||||
|
||||
# `signOut()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: resetPassword()
|
||||
sidebar_label: resetPassword()
|
||||
slug: /reference/javascript/auth/reset-password
|
||||
description: Use `nhost.auth.resetPassword` to reset the password for a user. This will send a reset-password link in an email to the user. When the user clicks the reset-password link the user is automatically signed-in. Once signed-in, the user can change their password using `nhost.auth.changePassword()`.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L272
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L238
|
||||
---
|
||||
|
||||
# `resetPassword()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: changePassword()
|
||||
sidebar_label: changePassword()
|
||||
slug: /reference/javascript/auth/change-password
|
||||
description: Use `nhost.auth.changePassword` to change the password for the user. The old password is not needed.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L288
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L254
|
||||
---
|
||||
|
||||
# `changePassword()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: sendVerificationEmail()
|
||||
sidebar_label: sendVerificationEmail()
|
||||
slug: /reference/javascript/auth/send-verification-email
|
||||
description: Use `nhost.auth.sendVerificationEmail` to send a verification email to the specified email. The email contains a verification-email link. When the user clicks the verification-email link their email is verified.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L304
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L270
|
||||
---
|
||||
|
||||
# `sendVerificationEmail()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: changeEmail()
|
||||
sidebar_label: changeEmail()
|
||||
slug: /reference/javascript/auth/change-email
|
||||
description: Use `nhost.auth.changeEmail` to change a user's email. This will send a confirm-email-change link in an email to the new email. Once the user clicks on the confirm-email-change link the email will be change to the new email.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L323
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L289
|
||||
---
|
||||
|
||||
# `changeEmail()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: deanonymize()
|
||||
sidebar_label: deanonymize()
|
||||
slug: /reference/javascript/auth/deanonymize
|
||||
description: Use `nhost.auth.deanonymize` to deanonymize a user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L339
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L305
|
||||
---
|
||||
|
||||
# `deanonymize()`
|
||||
@@ -24,13 +24,4 @@ nhost.auth.deanonymize({
|
||||
|
||||
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`DeanonymizeParams`](/reference/docgen/javascript/auth/types/deanonymize-params)
|
||||
|
||||
| Property | Type | Required | Notes |
|
||||
| :---------------------------------------------------------------------------------------------- | :------------------------------------- | :------: | :---- |
|
||||
| <span className="parameter-name"><span className="light-grey">params.</span>email</span> | `string` | ✔️ | |
|
||||
| <span className="parameter-name"><span className="light-grey">params.</span>signInMethod</span> | `"email-password"` \| `"passwordless"` | ✔️ | |
|
||||
| <span className="parameter-name"><span className="light-grey">params.</span>allowedRoles</span> | `Array<string>` | | |
|
||||
| <span className="parameter-name"><span className="light-grey">params.</span>defaultRole</span> | `string` | | |
|
||||
| <span className="parameter-name"><span className="light-grey">params.</span>connection</span> | `"email"` \| `"sms"` | | |
|
||||
| <span className="parameter-name"><span className="light-grey">params.</span>password</span> | `string` | | |
|
||||
|
||||
---
|
||||
|
||||
@@ -4,7 +4,7 @@ title: onTokenChanged()
|
||||
sidebar_label: onTokenChanged()
|
||||
slug: /reference/javascript/auth/on-token-changed
|
||||
description: Use `nhost.auth.onTokenChanged` to add a custom function that runs every time the access or refresh token is changed.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L373
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L348
|
||||
---
|
||||
|
||||
# `onTokenChanged()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: onAuthStateChanged()
|
||||
sidebar_label: onAuthStateChanged()
|
||||
slug: /reference/javascript/auth/on-auth-state-changed
|
||||
description: Use `nhost.auth.onAuthStateChanged` to add a custom function that runs every time the authentication status of the user changes. E.g. add a custom function that runs every time the authentication status changes from signed-in to signed-out.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L408
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L383
|
||||
---
|
||||
|
||||
# `onAuthStateChanged()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: isAuthenticated()
|
||||
sidebar_label: isAuthenticated()
|
||||
slug: /reference/javascript/auth/is-authenticated
|
||||
description: Use `nhost.auth.isAuthenticated` to check if the user is authenticated or not.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L450
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L425
|
||||
---
|
||||
|
||||
# `isAuthenticated()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: isAuthenticatedAsync()
|
||||
sidebar_label: isAuthenticatedAsync()
|
||||
slug: /reference/javascript/auth/is-authenticated-async
|
||||
description: Use `nhost.auth.isAuthenticatedAsync` to wait (await) for any internal authentication network requests to finish and then return the authentication status.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L468
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L443
|
||||
---
|
||||
|
||||
# `isAuthenticatedAsync()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getAuthenticationStatus()
|
||||
sidebar_label: getAuthenticationStatus()
|
||||
slug: /reference/javascript/auth/get-authentication-status
|
||||
description: Use `nhost.auth.getAuthenticationStatus` to get the authentication status of the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L494
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L469
|
||||
---
|
||||
|
||||
# `getAuthenticationStatus()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getAccessToken()
|
||||
sidebar_label: getAccessToken()
|
||||
slug: /reference/javascript/auth/get-access-token
|
||||
description: Use `nhost.auth.getAccessToken` to get the access token of the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L524
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L499
|
||||
---
|
||||
|
||||
# `getAccessToken()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getDecodedAccessToken()
|
||||
sidebar_label: getDecodedAccessToken()
|
||||
slug: /reference/javascript/auth/get-decoded-access-token
|
||||
description: Use `nhost.auth.getDecodedAccessToken` to get the decoded access token of the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L539
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L514
|
||||
---
|
||||
|
||||
# `getDecodedAccessToken()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getHasuraClaims()
|
||||
sidebar_label: getHasuraClaims()
|
||||
slug: /reference/javascript/auth/get-hasura-claims
|
||||
description: Use `nhost.auth.getHasuraClaims` to get the Hasura claims of the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L556
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L531
|
||||
---
|
||||
|
||||
# `getHasuraClaims()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getHasuraClaim()
|
||||
sidebar_label: getHasuraClaim()
|
||||
slug: /reference/javascript/auth/get-hasura-claim
|
||||
description: Use `nhost.auth.getHasuraClaim` to get the value of a specific Hasura claim of the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L574
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L549
|
||||
---
|
||||
|
||||
# `getHasuraClaim()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: refreshSession()
|
||||
sidebar_label: refreshSession()
|
||||
slug: /reference/javascript/auth/refresh-session
|
||||
description: Use `nhost.auth.refreshSession` to refresh the session with either the current internal refresh token or an external refresh token.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L597
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L572
|
||||
---
|
||||
|
||||
# `refreshSession()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getSession()
|
||||
sidebar_label: getSession()
|
||||
slug: /reference/javascript/auth/get-session
|
||||
description: Use `nhost.auth.getSession()` to get the session of the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L641
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L616
|
||||
---
|
||||
|
||||
# `getSession()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: getUser()
|
||||
sidebar_label: getUser()
|
||||
slug: /reference/javascript/auth/get-user
|
||||
description: Use `nhost.auth.getUser()` to get the signed-in user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L656
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L631
|
||||
---
|
||||
|
||||
# `getUser()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiChangeEmailResponse
|
||||
sidebar_label: ApiChangeEmailResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L178
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L181
|
||||
---
|
||||
|
||||
# `ApiChangeEmailResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiChangePasswordResponse
|
||||
sidebar_label: ApiChangePasswordResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L170
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L173
|
||||
---
|
||||
|
||||
# `ApiChangePasswordResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiDeanonymizeResponse
|
||||
sidebar_label: ApiDeanonymizeResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L182
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L185
|
||||
---
|
||||
|
||||
# `ApiDeanonymizeResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiRefreshTokenResponse
|
||||
sidebar_label: ApiRefreshTokenResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L158
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L161
|
||||
---
|
||||
|
||||
# `ApiRefreshTokenResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiResetPasswordResponse
|
||||
sidebar_label: ApiResetPasswordResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L166
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L169
|
||||
---
|
||||
|
||||
# `ApiResetPasswordResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiSendVerificationEmailResponse
|
||||
sidebar_label: ApiSendVerificationEmailResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L174
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L177
|
||||
---
|
||||
|
||||
# `ApiSendVerificationEmailResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiSignInData
|
||||
sidebar_label: ApiSignInData
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L147
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L150
|
||||
---
|
||||
|
||||
# `ApiSignInData`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiSignInResponse
|
||||
sidebar_label: ApiSignInResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L151
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L154
|
||||
---
|
||||
|
||||
# `ApiSignInResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiSignOutResponse
|
||||
sidebar_label: ApiSignOutResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L162
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L165
|
||||
---
|
||||
|
||||
# `ApiSignOutResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: ApiSignUpEmailPasswordResponse
|
||||
sidebar_label: ApiSignUpEmailPasswordResponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L143
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L146
|
||||
---
|
||||
|
||||
# `ApiSignUpEmailPasswordResponse`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: AuthChangeEvent
|
||||
sidebar_label: AuthChangeEvent
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L125
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L128
|
||||
---
|
||||
|
||||
# `AuthChangeEvent`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: AuthChangedFunction
|
||||
sidebar_label: AuthChangedFunction
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L127
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L130
|
||||
---
|
||||
|
||||
# `AuthChangedFunction`
|
||||
|
||||
@@ -4,35 +4,20 @@ title: DeanonymizeParams
|
||||
sidebar_label: DeanonymizeParams
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L105
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L104
|
||||
---
|
||||
|
||||
# `DeanonymizeParams`
|
||||
|
||||
## Parameters
|
||||
|
||||
---
|
||||
|
||||
**<span className="parameter-name">email</span>** <span className="optional-status">required</span> `string`
|
||||
|
||||
---
|
||||
|
||||
**<span className="parameter-name">signInMethod</span>** <span className="optional-status">required</span> `"email-password"` | `"passwordless"`
|
||||
|
||||
---
|
||||
|
||||
**<span className="parameter-name">allowedRoles</span>** <span className="optional-status">optional</span> `Array<string>`
|
||||
|
||||
---
|
||||
|
||||
**<span className="parameter-name">defaultRole</span>** <span className="optional-status">optional</span> `string`
|
||||
|
||||
---
|
||||
|
||||
**<span className="parameter-name">connection</span>** <span className="optional-status">optional</span> `"email"` | `"sms"`
|
||||
|
||||
---
|
||||
|
||||
**<span className="parameter-name">password</span>** <span className="optional-status">optional</span> `string`
|
||||
|
||||
---
|
||||
```ts
|
||||
type DeanonymizeParams =
|
||||
| ({ signInMethod: 'email-password' } & SignUpParams)
|
||||
| ({
|
||||
signInMethod: 'passwordless'
|
||||
connection: 'email'
|
||||
} & SignInPasswordlessEmailParams)
|
||||
| ({
|
||||
signInMethod: 'passwordless'
|
||||
connection: 'sms'
|
||||
} & SignInPasswordlessSmsParams)
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@ title: Headers
|
||||
sidebar_label: Headers
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L136
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L139
|
||||
---
|
||||
|
||||
# `Headers`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: LoginData
|
||||
sidebar_label: LoginData
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L131
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L134
|
||||
---
|
||||
|
||||
# `LoginData`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: Mfa
|
||||
sidebar_label: Mfa
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L139
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L142
|
||||
---
|
||||
|
||||
# `Mfa`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: OnTokenChangedFunction
|
||||
sidebar_label: OnTokenChangedFunction
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L129
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L132
|
||||
---
|
||||
|
||||
# `OnTokenChangedFunction`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: SignInReponse
|
||||
sidebar_label: SignInReponse
|
||||
description: No description provided.
|
||||
displayed_sidebar: referenceSidebar
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L114
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L117
|
||||
---
|
||||
|
||||
# `SignInReponse`
|
||||
|
||||
@@ -3,8 +3,26 @@
|
||||
title: useSignInAnonymous()
|
||||
sidebar_label: useSignInAnonymous()
|
||||
slug: /reference/nextjs/use-sign-in-anonymous
|
||||
description: No description provided.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInAnonymous.ts#L9
|
||||
description: Use the hook `useSignInAnonymous` to sign in a user anonymously.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInAnonymous.ts#L27
|
||||
---
|
||||
|
||||
# `useSignInAnonymous()`
|
||||
|
||||
Use the hook `useSignInAnonymous` to sign in a user anonymously.
|
||||
|
||||
As a result, the user will have the `anonymous` role and subsequent set of permissions.
|
||||
The user can then be converted to a regular user at a later stage using email+password sign-up, passwordless email (magic link), or passwordless SMS.
|
||||
|
||||
```tsx
|
||||
const { signInAnonymous, isLoading, isSuccess, isError, error } =
|
||||
useSignInAnonymous()
|
||||
|
||||
console.log({ isLoading, isSuccess, isError, error })
|
||||
|
||||
const handleFormSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
await signInAnonymous()
|
||||
}
|
||||
```
|
||||
|
||||
@@ -3,8 +3,26 @@
|
||||
title: useSignInAnonymous()
|
||||
sidebar_label: useSignInAnonymous()
|
||||
slug: /reference/react/use-sign-in-anonymous
|
||||
description: No description provided.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInAnonymous.ts#L9
|
||||
description: Use the hook `useSignInAnonymous` to sign in a user anonymously.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInAnonymous.ts#L27
|
||||
---
|
||||
|
||||
# `useSignInAnonymous()`
|
||||
|
||||
Use the hook `useSignInAnonymous` to sign in a user anonymously.
|
||||
|
||||
As a result, the user will have the `anonymous` role and subsequent set of permissions.
|
||||
The user can then be converted to a regular user at a later stage using email+password sign-up, passwordless email (magic link), or passwordless SMS.
|
||||
|
||||
```tsx
|
||||
const { signInAnonymous, isLoading, isSuccess, isError, error } =
|
||||
useSignInAnonymous()
|
||||
|
||||
console.log({ isLoading, isSuccess, isError, error })
|
||||
|
||||
const handleFormSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
await signInAnonymous()
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||
title: useSignInAnonymous()
|
||||
sidebar_label: useSignInAnonymous()
|
||||
slug: /reference/vue/use-sign-in-anonymous
|
||||
description: Use the composable `useSignInAnonymous` to sign in a user anonymously.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInAnonymous.ts#L31
|
||||
---
|
||||
|
||||
# `useSignInAnonymous()`
|
||||
|
||||
Use the composable `useSignInAnonymous` to sign in a user anonymously.
|
||||
|
||||
As a result, the user will have the `anonymous` role and subsequent set of permissions.
|
||||
The user can then be converted to a regular user at a later stage using email+password sign-up, passwordless email (magic link), or passwordless SMS.
|
||||
|
||||
```tsx
|
||||
const { signInAnonymous, isLoading, isSuccess, isError, error } =
|
||||
useSignInAnonymous()
|
||||
|
||||
watchEffect(() => {
|
||||
console.log(isLoading.value, isSuccess.value, isError.value, error.value)
|
||||
})
|
||||
|
||||
const handleFormSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
await signInAnonymous()
|
||||
}
|
||||
```
|
||||
@@ -4,9 +4,20 @@ title: useSignOut()
|
||||
sidebar_label: useSignOut()
|
||||
slug: /reference/vue/use-sign-out
|
||||
description: Use the composable `useSignOut` to sign out the user.
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignOut.ts#L14
|
||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignOut.ts#L27
|
||||
---
|
||||
|
||||
# `useSignOut()`
|
||||
|
||||
Use the composable `useSignOut` to sign out the user.
|
||||
|
||||
```jsx
|
||||
import { useSignOut } from '@nhost/vue'
|
||||
|
||||
const { signOut, isSuccess } = useSignOut()
|
||||
|
||||
const handleSignOut = async (e) => {
|
||||
e.preventDefault()
|
||||
await signOut()
|
||||
}
|
||||
```
|
||||
|
||||
11
examples/react-apollo/cypress.config.ts
Normal file
11
examples/react-apollo/cypress.config.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { defineConfig } from 'cypress'
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:3000',
|
||||
chromeWebSecurity: false,
|
||||
// * for some reason, the mailhog API is not systematically available
|
||||
// * when using `localhost` instead of `127.0.0.1`
|
||||
mailHogUrl: 'http://127.0.0.1:8025'
|
||||
}
|
||||
} as Cypress.ConfigOptions)
|
||||
@@ -0,0 +1,12 @@
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
context('Failed attempt to sign up with an email already present in the database', () => {
|
||||
it('shoud raise an error when trying to sign up with an existing email', () => {
|
||||
const email = faker.internet.email()
|
||||
const password = faker.internet.password(10)
|
||||
cy.signUpEmailPassword(email, password)
|
||||
cy.contains('Verification email sent').should('be.visible')
|
||||
cy.signUpEmailPassword(email, password)
|
||||
cy.contains('Email already in use').should('be.visible')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
context('Successful email+password sign-up', () => {
|
||||
it('should redirect to /sign-in when not authenticated', () => {
|
||||
cy.visit('/')
|
||||
cy.location('pathname').should('equal', '/sign-in')
|
||||
})
|
||||
|
||||
it('should sign-up with email and password', () => {
|
||||
const email = faker.internet.email()
|
||||
cy.signUpEmailPassword(email, faker.internet.password())
|
||||
cy.contains('Verification email sent').should('be.visible')
|
||||
cy.confirmEmail(email)
|
||||
cy.contains('You are authenticated')
|
||||
})
|
||||
})
|
||||
31
examples/react-apollo/cypress/support/e2e.ts
Normal file
31
examples/react-apollo/cypress/support/e2e.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { faker } from '@faker-js/faker'
|
||||
import '@testing-library/cypress/add-commands'
|
||||
import 'cypress-mailhog'
|
||||
|
||||
declare global {
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
signUpEmailPassword(email: string, password: string): Chainable<Element>
|
||||
confirmEmail(email: string): Chainable<Element>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cypress.Commands.add('signUpEmailPassword', (email, password) => {
|
||||
cy.visit('/sign-up')
|
||||
cy.contains('Continue with email + password').click()
|
||||
cy.findByPlaceholderText('First name').type(faker.name.firstName())
|
||||
cy.findByPlaceholderText('Last name').type(faker.name.lastName())
|
||||
cy.findByPlaceholderText('Email Address').type(email)
|
||||
cy.findByPlaceholderText('Password').type(password)
|
||||
cy.findByPlaceholderText('Confirm Password').type(password)
|
||||
cy.contains('Continue with email + password').click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add('confirmEmail', (email) => {
|
||||
cy.mhGetMailsByRecipient(email)
|
||||
.should('have.length', 1)
|
||||
.then(([message]) => {
|
||||
cy.visit(message.Content.Headers['X-Link'][0])
|
||||
})
|
||||
})
|
||||
@@ -3,11 +3,13 @@ services:
|
||||
mailhog:
|
||||
port: 8025
|
||||
hasura:
|
||||
version: v2.2.0
|
||||
version: v2.7.0
|
||||
environment:
|
||||
hasura_graphql_enable_remote_schema_permissions: false
|
||||
auth:
|
||||
version: 0.7.1
|
||||
version: 0.9.0
|
||||
storage:
|
||||
version: 0.2.1
|
||||
auth:
|
||||
access_control:
|
||||
email:
|
||||
|
||||
@@ -2,6 +2,7 @@ table:
|
||||
name: provider_requests
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config: {}
|
||||
custom_column_names: {}
|
||||
custom_name: authProviderRequests
|
||||
custom_root_fields:
|
||||
|
||||
@@ -2,6 +2,7 @@ table:
|
||||
name: providers
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config: {}
|
||||
custom_column_names: {}
|
||||
custom_name: authProviders
|
||||
custom_root_fields:
|
||||
|
||||
@@ -2,6 +2,15 @@ table:
|
||||
name: refresh_tokens
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config:
|
||||
created_at:
|
||||
custom_name: createdAt
|
||||
expires_at:
|
||||
custom_name: expiresAt
|
||||
refresh_token:
|
||||
custom_name: refreshToken
|
||||
user_id:
|
||||
custom_name: userId
|
||||
custom_column_names:
|
||||
created_at: createdAt
|
||||
expires_at: expiresAt
|
||||
|
||||
@@ -2,6 +2,7 @@ table:
|
||||
name: roles
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config: {}
|
||||
custom_column_names: {}
|
||||
custom_name: authRoles
|
||||
custom_root_fields:
|
||||
|
||||
@@ -2,6 +2,21 @@ table:
|
||||
name: user_providers
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config:
|
||||
access_token:
|
||||
custom_name: accessToken
|
||||
created_at:
|
||||
custom_name: createdAt
|
||||
provider_id:
|
||||
custom_name: providerId
|
||||
provider_user_id:
|
||||
custom_name: providerUserId
|
||||
refresh_token:
|
||||
custom_name: refreshToken
|
||||
updated_at:
|
||||
custom_name: updatedAt
|
||||
user_id:
|
||||
custom_name: userId
|
||||
custom_column_names:
|
||||
access_token: accessToken
|
||||
created_at: createdAt
|
||||
|
||||
@@ -2,6 +2,11 @@ table:
|
||||
name: user_roles
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config:
|
||||
created_at:
|
||||
custom_name: createdAt
|
||||
user_id:
|
||||
custom_name: userId
|
||||
custom_column_names:
|
||||
created_at: createdAt
|
||||
user_id: userId
|
||||
|
||||
@@ -2,6 +2,43 @@ table:
|
||||
name: users
|
||||
schema: auth
|
||||
configuration:
|
||||
column_config:
|
||||
active_mfa_type:
|
||||
custom_name: activeMfaType
|
||||
avatar_url:
|
||||
custom_name: avatarUrl
|
||||
created_at:
|
||||
custom_name: createdAt
|
||||
default_role:
|
||||
custom_name: defaultRole
|
||||
display_name:
|
||||
custom_name: displayName
|
||||
email_verified:
|
||||
custom_name: emailVerified
|
||||
is_anonymous:
|
||||
custom_name: isAnonymous
|
||||
last_seen:
|
||||
custom_name: lastSeen
|
||||
new_email:
|
||||
custom_name: newEmail
|
||||
otp_hash:
|
||||
custom_name: otpHash
|
||||
otp_hash_expires_at:
|
||||
custom_name: otpHashExpiresAt
|
||||
otp_method_last_used:
|
||||
custom_name: otpMethodLastUsed
|
||||
password_hash:
|
||||
custom_name: passwordHash
|
||||
phone_number:
|
||||
custom_name: phoneNumber
|
||||
phone_number_verified:
|
||||
custom_name: phoneNumberVerified
|
||||
ticket_expires_at:
|
||||
custom_name: ticketExpiresAt
|
||||
totp_secret:
|
||||
custom_name: totpSecret
|
||||
updated_at:
|
||||
custom_name: updatedAt
|
||||
custom_column_names:
|
||||
active_mfa_type: activeMfaType
|
||||
avatar_url: avatarUrl
|
||||
|
||||
@@ -2,6 +2,23 @@ table:
|
||||
name: buckets
|
||||
schema: storage
|
||||
configuration:
|
||||
column_config:
|
||||
cache_control:
|
||||
custom_name: cacheControl
|
||||
created_at:
|
||||
custom_name: createdAt
|
||||
download_expiration:
|
||||
custom_name: downloadExpiration
|
||||
id:
|
||||
custom_name: id
|
||||
max_upload_file_size:
|
||||
custom_name: maxUploadFileSize
|
||||
min_upload_file_size:
|
||||
custom_name: minUploadFileSize
|
||||
presigned_urls_enabled:
|
||||
custom_name: presignedUrlsEnabled
|
||||
updated_at:
|
||||
custom_name: updatedAt
|
||||
custom_column_names:
|
||||
cache_control: cacheControl
|
||||
created_at: createdAt
|
||||
|
||||
@@ -2,6 +2,27 @@ table:
|
||||
name: files
|
||||
schema: storage
|
||||
configuration:
|
||||
column_config:
|
||||
bucket_id:
|
||||
custom_name: bucketId
|
||||
created_at:
|
||||
custom_name: createdAt
|
||||
etag:
|
||||
custom_name: etag
|
||||
id:
|
||||
custom_name: id
|
||||
is_uploaded:
|
||||
custom_name: isUploaded
|
||||
mime_type:
|
||||
custom_name: mimeType
|
||||
name:
|
||||
custom_name: name
|
||||
size:
|
||||
custom_name: size
|
||||
updated_at:
|
||||
custom_name: updatedAt
|
||||
uploaded_by_user_id:
|
||||
custom_name: uploadedByUserId
|
||||
custom_column_names:
|
||||
bucket_id: bucketId
|
||||
created_at: createdAt
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
"@mantine/hooks": "^4.2.2",
|
||||
"@mantine/notifications": "^4.2.2",
|
||||
"@mantine/prism": "^4.2.2",
|
||||
"@nhost/react": "workspace:*",
|
||||
"@nhost/react-apollo": "workspace:*",
|
||||
"@nhost/react": "*",
|
||||
"@nhost/react-apollo": "*",
|
||||
"graphql": "15.7.2",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
@@ -17,11 +17,15 @@
|
||||
"react-router": "^6.3.0",
|
||||
"react-router-dom": "^6.3.0"
|
||||
},
|
||||
"lib": "workspace:*",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"cypress": "cypress open",
|
||||
"test": "cypress run",
|
||||
"e2e": "start-test e2e:backend :1337/v1/auth/healthz e2e:frontend 3000 test",
|
||||
"e2e:backend": "nhost dev --no-browser",
|
||||
"e2e:frontend": "run-s build preview",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"preview": "vite preview --host localhost --port 3000",
|
||||
"prettier": "prettier --check .",
|
||||
"prettier:fix": "prettier --write .",
|
||||
"lint": "eslint . --ext .ts,.tsx",
|
||||
@@ -47,12 +51,18 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@faker-js/faker": "^6.3.1",
|
||||
"@testing-library/cypress": "^8.0.3",
|
||||
"@types/react": "^18.0.8",
|
||||
"@types/react-dom": "^18.0.3",
|
||||
"@vitejs/plugin-react": "^1.3.2",
|
||||
"@xstate/inspect": "^0.6.2",
|
||||
"cypress": "^10.0.1",
|
||||
"cypress-mailhog": "^1.4.0",
|
||||
"start-server-and-test": "^1.14.0",
|
||||
"typescript": "^4.6.3",
|
||||
"vite": "^2.9.7",
|
||||
"ws": "^8.7.0",
|
||||
"xstate": "^4.31.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,12 @@
|
||||
import { Container, Title } from '@mantine/core'
|
||||
import { useNhostClient, useSignInAnonymous } from '@nhost/react'
|
||||
import React from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { Container, Title } from '@mantine/core'
|
||||
|
||||
export const AboutPage: React.FC = () => {
|
||||
const nhost = useNhostClient()
|
||||
const { signInAnonymous } = useSignInAnonymous()
|
||||
const fetch = async () => {
|
||||
const req = await nhost.graphql.request(`query BooksQuery {
|
||||
books {
|
||||
id
|
||||
title
|
||||
}
|
||||
}`)
|
||||
console.log(req)
|
||||
}
|
||||
return (
|
||||
<Container>
|
||||
<Title>About this example</Title>
|
||||
<button
|
||||
onClick={async () => {
|
||||
const result = await signInAnonymous()
|
||||
console.log(result)
|
||||
}}
|
||||
>
|
||||
ANONYMOUS
|
||||
</button>
|
||||
<p>This application demonstrates the available features of the Nhost stack.</p>
|
||||
<button onClick={fetch}>Fetch</button>
|
||||
<div>
|
||||
Nhost cloud leverages the following services in the backend:
|
||||
<ul>
|
||||
@@ -47,7 +26,7 @@ export const AboutPage: React.FC = () => {
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
Noew let's go to the <Link to="/">index page</Link>
|
||||
Now let's go to the <Link to="/">index page</Link>
|
||||
</div>
|
||||
</Container>
|
||||
)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
import { Route, Routes } from 'react-router-dom'
|
||||
|
||||
import { AppShell, Header, MantineProvider } from '@mantine/core'
|
||||
import { NotificationsProvider } from '@mantine/notifications'
|
||||
|
||||
import { AuthGate, PublicGate } from './components/auth-gates'
|
||||
import NavBar from './components/NavBar'
|
||||
import { AboutPage } from './About'
|
||||
import { ApolloPage } from './apollo'
|
||||
import Home from './Home'
|
||||
@@ -10,9 +13,6 @@ import { SignInPage } from './sign-in'
|
||||
import { SignUpPage } from './sign-up'
|
||||
|
||||
import './App.css'
|
||||
import NavBar from './components/NavBar'
|
||||
import { MantineProvider, AppShell, Header } from '@mantine/core'
|
||||
import { NotificationsProvider } from '@mantine/notifications'
|
||||
const title = 'Nhost with React and Apollo'
|
||||
|
||||
function App() {
|
||||
@@ -62,7 +62,7 @@ function App() {
|
||||
<Route
|
||||
path="/sign-up/*"
|
||||
element={
|
||||
<PublicGate>
|
||||
<PublicGate anonymous>
|
||||
<SignUpPage />
|
||||
</PublicGate>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Container, Title } from '@mantine/core'
|
||||
import React from 'react'
|
||||
|
||||
const HomePage: React.FC = () => {
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React from 'react'
|
||||
|
||||
import { gql } from '@apollo/client'
|
||||
import { useAuthQuery } from '@nhost/react-apollo'
|
||||
import { Container, Loader, Title } from '@mantine/core'
|
||||
import { useAuthQuery } from '@nhost/react-apollo'
|
||||
|
||||
const GET_BOOKS = gql`
|
||||
query BooksQuery {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { Button, ButtonVariant } from '@mantine/core'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
const AuthLink: React.FC<{
|
||||
icon?: React.ReactNode
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { FaHouseUser, FaQuestion, FaSignOutAlt } from 'react-icons/fa'
|
||||
import { SiApollographql } from 'react-icons/si'
|
||||
import { useLocation,useNavigate } from 'react-router'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import { Group, MantineColor, Navbar, Text, ThemeIcon, UnstyledButton } from '@mantine/core'
|
||||
import { useAuthenticated, useSignOut } from '@nhost/react'
|
||||
import { useNavigate, useLocation } from 'react-router'
|
||||
import { Link } from 'react-router-dom'
|
||||
interface MenuItemProps {
|
||||
icon: React.ReactNode
|
||||
color?: MantineColor
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from 'react'
|
||||
import { FaFacebook, FaGithub, FaGoogle } from 'react-icons/fa'
|
||||
import { FaFacebook, FaGithub, FaGoogle } from 'react-icons/fa/index.js'
|
||||
|
||||
import { useProviderLink } from '@nhost/react'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import { Navigate, useLocation } from 'react-router-dom'
|
||||
|
||||
import { useAuthenticationStatus } from '@nhost/react'
|
||||
import { useUserIsAnonymous } from '@nhost/react'
|
||||
|
||||
export const AuthGate: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
|
||||
const { isLoading, isAuthenticated } = useAuthenticationStatus()
|
||||
@@ -17,14 +17,20 @@ export const AuthGate: React.FC<React.PropsWithChildren<unknown>> = ({ children
|
||||
return <div>{children}</div>
|
||||
}
|
||||
|
||||
export const PublicGate: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
|
||||
export const PublicGate: React.FC<
|
||||
React.PropsWithChildren<{
|
||||
/** Set to `true` if you want this route to be accessible to anonymous users */
|
||||
anonymous?: boolean
|
||||
}>
|
||||
> = ({ anonymous, children }) => {
|
||||
const { isLoading, isAuthenticated } = useAuthenticationStatus()
|
||||
const isAnonymous = useUserIsAnonymous()
|
||||
const location = useLocation()
|
||||
if (isLoading) {
|
||||
return <div>Loading...</div>
|
||||
}
|
||||
|
||||
if (isAuthenticated) {
|
||||
if (isAuthenticated && !anonymous && isAnonymous) {
|
||||
return <Navigate to={'/'} state={{ from: location }} replace />
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import React from 'react'
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
|
||||
import { NhostClient, NhostReactProvider } from '@nhost/react'
|
||||
@@ -8,7 +7,7 @@ import { inspect } from '@xstate/inspect'
|
||||
|
||||
import App from './App'
|
||||
|
||||
const devTools = !!import.meta.env.VITE_DEBUG
|
||||
const devTools = import.meta.env.MODE === 'development' && import.meta.env.VITE_DEBUG === 'true'
|
||||
if (devTools) {
|
||||
inspect({
|
||||
url: 'https://stately.ai/viz?inspect',
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
import { useState } from 'react'
|
||||
|
||||
import { useChangeEmail, useUserEmail } from '@nhost/react'
|
||||
import { Button, Card, Grid, TextInput, Title } from '@mantine/core'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { useChangeEmail, useUserEmail } from '@nhost/react'
|
||||
|
||||
export const ChangeEmail: React.FC = () => {
|
||||
const [newEmail, setNewEmail] = useState('')
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import React from 'react'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { useChangePassword } from '@nhost/react'
|
||||
import { Button, Card, Grid, PasswordInput, Title } from '@mantine/core'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { useChangePassword } from '@nhost/react'
|
||||
|
||||
export const ChangePassword: React.FC = () => {
|
||||
const [password, setPassword] = useState('')
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Button, Card, Container, Title } from '@mantine/core'
|
||||
import { Prism } from '@mantine/prism'
|
||||
import { useHasuraClaims, useNhostClient, useUserData } from '@nhost/react'
|
||||
|
||||
import { ChangeEmail } from './change-email'
|
||||
import { ChangePassword } from './change-password'
|
||||
import { Mfa } from './mfa'
|
||||
import { Button, Card, Container, Title } from '@mantine/core'
|
||||
import { Prism } from '@mantine/prism'
|
||||
|
||||
export const ProfilePage: React.FC = () => {
|
||||
const claims = useHasuraClaims()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import React from 'react'
|
||||
import { useState } from 'react'
|
||||
|
||||
import { useConfigMfa } from '@nhost/react'
|
||||
import { Card, Button, TextInput, Title } from '@mantine/core'
|
||||
import { Button, Card, TextInput, Title } from '@mantine/core'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { useConfigMfa } from '@nhost/react'
|
||||
|
||||
export const Mfa: React.FC = () => {
|
||||
const [code, setCode] = useState('')
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { useSignInEmailPassword } from '@nhost/react'
|
||||
import { Button, Modal, TextInput } from '@mantine/core'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { useSignInEmailPassword } from '@nhost/react'
|
||||
|
||||
import AuthLink from '../components/AuthLink'
|
||||
|
||||
export const EmailPassword: React.FC = () => {
|
||||
const [email, setEmail] = useState('')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Divider } from '@mantine/core'
|
||||
import React from 'react'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import EmailPasswordlessForm from '../components/SignUpServerlessForm'
|
||||
|
||||
export const EmailPasswordless: React.FC = () => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { useState } from 'react'
|
||||
|
||||
import { useResetPassword } from '@nhost/react'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { Button, Divider, TextInput } from '@mantine/core'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { useResetPassword } from '@nhost/react'
|
||||
|
||||
import AuthLink from '../components/AuthLink'
|
||||
|
||||
export const ForgotPassword: React.FC = () => {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import React from 'react'
|
||||
import { FaLock } from 'react-icons/fa'
|
||||
import { Link, Route, Routes } from 'react-router-dom'
|
||||
import { Link, Route, Routes, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { Anchor, Center, Divider, Text } from '@mantine/core'
|
||||
|
||||
import AuthLayout from '../components/AuthLayout'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import OAuthLinks from '../components/OauthLinks'
|
||||
|
||||
import { EmailPassword } from './email-password'
|
||||
import { EmailPasswordless } from './email-passwordless'
|
||||
import AuthLayout from '../components/AuthLayout'
|
||||
import { Center, Text, Anchor, Divider } from '@mantine/core'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import { ForgotPassword } from './forgot-password'
|
||||
import { useSignInAnonymous } from '@nhost/react'
|
||||
|
||||
const Index: React.FC = () => (
|
||||
<>
|
||||
@@ -24,6 +25,15 @@ const Index: React.FC = () => (
|
||||
</>
|
||||
)
|
||||
export const SignInPage: React.FC = () => {
|
||||
const { signInAnonymous } = useSignInAnonymous()
|
||||
const navigate = useNavigate()
|
||||
const anonymousHandler = async () => {
|
||||
const { isSuccess } = await signInAnonymous()
|
||||
if (isSuccess) {
|
||||
navigate('/')
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthLayout
|
||||
title="Log in to the Application"
|
||||
@@ -33,7 +43,8 @@ export const SignInPage: React.FC = () => {
|
||||
Don‘t have an account?{' '}
|
||||
<Anchor component={Link} to="/sign-up">
|
||||
Sign up
|
||||
</Anchor>
|
||||
</Anchor>{' '}
|
||||
or <Anchor onClick={anonymousHandler}>sign in anonymously</Anchor>
|
||||
</Text>
|
||||
</Center>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { useSignUpEmailPassword } from '@nhost/react'
|
||||
import { Button, Divider, Modal, PasswordInput, SimpleGrid, TextInput } from '@mantine/core'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import { showNotification } from '@mantine/notifications'
|
||||
import { useSignUpEmailPassword } from '@nhost/react'
|
||||
|
||||
import AuthLink from '../components/AuthLink'
|
||||
|
||||
export const EmailPassword: React.FC = () => {
|
||||
const [email, setEmail] = useState('')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Divider } from '@mantine/core'
|
||||
import React from 'react'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import EmailPasswordlessForm from '../components/SignUpServerlessForm'
|
||||
|
||||
export const EmailPasswordless: React.FC = () => {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React from 'react'
|
||||
import { FaLock } from 'react-icons/fa'
|
||||
import { Link, Route, Routes } from 'react-router-dom'
|
||||
|
||||
import { Anchor, Center, Divider, Text } from '@mantine/core'
|
||||
|
||||
import AuthLayout from '../components/AuthLayout'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
import OAuthLinks from '../components/OauthLinks'
|
||||
|
||||
import { EmailPassword } from './email-password'
|
||||
import { EmailPasswordless } from './email-passwordless'
|
||||
import AuthLayout from '../components/AuthLayout'
|
||||
import { Center, Text, Anchor, Divider } from '@mantine/core'
|
||||
import AuthLink from '../components/AuthLink'
|
||||
|
||||
const Index: React.FC = () => (
|
||||
<>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../../config/tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
@@ -13,10 +13,10 @@
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"isolatedModules": false,
|
||||
"noEmit": true,
|
||||
"types": ["node", "cypress", "@testing-library/cypress"],
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "../../config/tsconfig.base.json" }]
|
||||
"include": ["src", "cypress", "cypress.config.ts"]
|
||||
}
|
||||
|
||||
2
examples/testing-project/.gitignore
vendored
2
examples/testing-project/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
.nhost
|
||||
node_modules
|
||||
@@ -1,7 +0,0 @@
|
||||
# @nhost-examples/testing-project
|
||||
|
||||
## 1.0.1
|
||||
### Patch Changes
|
||||
|
||||
- a880583: - Improve typings (close [this PR](https://github.com/nhost/hasura-auth-js/pull/15))
|
||||
- Add the metadata field introduced in [hasura-auth 0.2.0](https://github.com/nhost/hasura-auth/releases/tag/v0.2.0) (close [this PR](https://github.com/nhost/hasura-auth-js/pull/18))
|
||||
@@ -1,11 +0,0 @@
|
||||
# Empty Nhost project
|
||||
|
||||
Empty Nhost project, that can be spawned for testing of development purpose.
|
||||
|
||||
When on this directory, run the command:
|
||||
|
||||
```sh
|
||||
nhost
|
||||
```
|
||||
|
||||
An all-in local Nhost instance will then start.
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "@nhost-examples/testing-project",
|
||||
"private": true,
|
||||
"version": "1.0.1",
|
||||
"description": "Wrapper to run the Nhost CLI for development and testing",
|
||||
"scripts": {
|
||||
"start": "nhost -d"
|
||||
},
|
||||
"author": "Pierre-Louis Mercereau",
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -1,17 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { useSignInAnonymous } from '@nhost/vue'
|
||||
const { signInAnonymous } = useSignInAnonymous()
|
||||
const router = useRouter()
|
||||
const handleSignInAnonymous = async (e: Event) => {
|
||||
e.preventDefault()
|
||||
const { isSuccess, error } = await signInAnonymous()
|
||||
if (isSuccess) {
|
||||
router.push('/profile')
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div className="d-flex align-center flex-column">
|
||||
<v-card width="400">
|
||||
<v-card-title>Log in to the Application</v-card-title>
|
||||
<v-card-text><router-view /></v-card-text>
|
||||
<v-card-text>
|
||||
<router-view />
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-divider
|
||||
class="my-4"
|
||||
style="min-width: 90%"
|
||||
/>
|
||||
<v-divider class="my-4" style="min-width: 90%" />
|
||||
<div>
|
||||
Don‘t have an account? <router-link to="/signup">
|
||||
Sign up
|
||||
</router-link>
|
||||
</router-link> or <a href="#" @click="handleSignInAnonymous">sign in anonymously</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
11
package.json
11
package.json
@@ -16,12 +16,12 @@
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"prepare": "husky install",
|
||||
"build": "turbo run build --filter=!@nhost/docs --filter=!@nhost-examples/* --no-deps --include-dependencies",
|
||||
"build:docs": "pnpm run build --filter=@nhost/docs",
|
||||
"build": "pnpm run build:all -- --filter=!@nhost/docs --filter=!@nhost-examples/*",
|
||||
"build:docs": "pnpm run build:all -- --filter=@nhost/docs",
|
||||
"build:all": "turbo run build --include-dependencies",
|
||||
"dev": "turbo run dev --filter=!@nhost/docs --filter=!@nhost-examples/* --filter=!@nhost/docgen --no-deps --include-dependencies",
|
||||
"clean:all": "pnpm clean && rm -rf ./{{packages,examples}/*,docs}/{.nhost,node_modules} node_modules",
|
||||
"clean": "rm -rf ./{{packages,examples}/*,docs}/{dist,umd,.next,.turbo,coverage}",
|
||||
"ci": "pnpm build && pnpm lint -- --filter=!@nhost/docs --filter=!@nhost-examples/*",
|
||||
"ci:version": "changeset version && pnpm install --frozen-lockfile false",
|
||||
"coverage": "pnpm run test --coverage",
|
||||
"prettier": "prettier --check .",
|
||||
@@ -32,8 +32,8 @@
|
||||
"release": "pnpm run prerelease && changeset publish",
|
||||
"snapshot": "pnpm prerelease && changeset version --snapshot preview && pnpm install && changeset publish --tag preview",
|
||||
"test": "turbo run test --filter=!@nhost/docs --filter=!@nhost-examples/* --no-deps --include-dependencies",
|
||||
"e2e": "turbo run e2e --concurrency=1",
|
||||
"changeset": "changeset",
|
||||
"wait": "wait-on http://localhost:1337/v1/auth/healthz -i 500 -t 120000",
|
||||
"docgen": "turbo run build --filter=@nhost/docgen --no-deps && turbo run docgen --filter='@nhost/*' && :"
|
||||
},
|
||||
"workspaces": [
|
||||
@@ -77,8 +77,7 @@
|
||||
"vite": "^2.9.7",
|
||||
"vite-plugin-dts": "^0.9.10",
|
||||
"vite-tsconfig-paths": "^3.4.1",
|
||||
"vitest": "^0.12.6",
|
||||
"wait-on": "^6.0.1"
|
||||
"vitest": "^0.12.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"graphql": "15.7.2"
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @nhost/apollo
|
||||
|
||||
## 0.5.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1613394]
|
||||
- @nhost/nhost-js@1.3.0
|
||||
|
||||
## 0.5.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 8b2d1b00: Add headers to the websocket connection when creating the Apollo client
|
||||
|
||||
## 0.5.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/apollo",
|
||||
"version": "0.5.13",
|
||||
"version": "0.5.15",
|
||||
"description": "Nhost Apollo Client library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -36,7 +36,7 @@ export const createApolloClient = ({
|
||||
cache = new InMemoryCache(),
|
||||
connectToDevTools = isBrowser && process.env.NODE_ENV === 'development',
|
||||
onError
|
||||
}: NhostApolloClientOptions): ApolloClient<unknown> => {
|
||||
}: NhostApolloClientOptions): ApolloClient<any> => {
|
||||
let backendUrl = graphqlUrl || nhost?.graphql.getUrl()
|
||||
if (!backendUrl) {
|
||||
throw Error("Can't initialize the Apollo Client: no backend Url has been provided")
|
||||
@@ -71,7 +71,10 @@ export const createApolloClient = ({
|
||||
createRestartableClient({
|
||||
url: uri.startsWith('https') ? uri.replace(/^https/, 'wss') : uri.replace(/^http/, 'ws'),
|
||||
connectionParams: () => ({
|
||||
headers: getAuthHeaders()
|
||||
headers: {
|
||||
...headers,
|
||||
...getAuthHeaders()
|
||||
}
|
||||
})
|
||||
})
|
||||
const wsLink = wsClient && new GraphQLWsLink(wsClient)
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @nhost/core
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- c1613394: Deanonymisation
|
||||
Once signed in anonymously, users can deanonymise using `nhost.auth.deanonymize`.
|
||||
Deanonymisation works the same way as email+password sign-up or passwordless sign-in. The related methods, hooks in React and composables in Vue can therefore be used for deanonymising users, such as `nhost.auth.signUp`, `useSignUpEmailPassword`, and `useSignInEmailPasswordless`.
|
||||
|
||||
## 0.6.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user