From 7d80698754b57b11ed0e94c1658e67d2a5e563f4 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Thu, 13 Feb 2020 21:48:01 -0500 Subject: [PATCH] Added README --- examples/with-passport/README.md | 48 +++++++++++++++++++++++++++++ examples/with-passport/package.json | 2 -- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 examples/with-passport/README.md diff --git a/examples/with-passport/README.md b/examples/with-passport/README.md new file mode 100644 index 000000000000..2e1259e1fe84 --- /dev/null +++ b/examples/with-passport/README.md @@ -0,0 +1,48 @@ +# Passport.js Example + +This example show how to use [Passport.js](http://www.passportjs.org) with Next.js. The example features cookie based authentication with username and password. + +The example shows how to do a login, signup and logout; and to get the user info using a hook with [SWR](https://swr.now.sh). + +A DB is not included, you can use any db you want and add it [here](/lib/user.js). + +The login cookie is httpOnly, meaning it can only be accessed by the API, and it's encrypted using [@hapi/iron](https://hapi.dev/family/iron) for more security. + +## Deploy your own + +Deploy the example using [ZEIT Now](https://zeit.co/now): + +[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/next.js/tree/canary/examples/with-passport) + +## How to use + +### Using `create-next-app` + +Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example: + +```bash +npm init next-app --example with-passport with-passport-app +# or +yarn create next-app --example with-passport with-passport-app +``` + +### Download manually + +Download the example [or clone the repo](https://github.com/zeit/next.js): + +```bash +curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-passport +cd with-passport +``` + +Install it and run: + +```bash +npm install +npm run dev +# or +yarn +yarn dev +``` + +Deploy it to the cloud with [ZEIT Now](https://zeit.co/new?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). diff --git a/examples/with-passport/package.json b/examples/with-passport/package.json index efbcb48bd1e7..5c15d1ca55a6 100644 --- a/examples/with-passport/package.json +++ b/examples/with-passport/package.json @@ -9,9 +9,7 @@ "@hapi/iron": "6.0.0", "cookie": "0.4.0", "express": "4.17.1", - "js-cookie": "latest", "next": "latest", - "next-cookies": "latest", "passport": "0.4.1", "passport-local": "1.0.0", "react": "latest",