Robert Hall 3d2098c250 Doh!
2018-09-24 20:49:04 -06:00
2018-09-24 20:49:04 -06:00
2018-09-24 20:22:12 -06:00
2018-09-24 20:02:10 -06:00
2017-12-17 19:35:01 -05:00
2018-09-08 15:47:31 -06:00
2018-09-24 20:49:04 -06:00
2018-04-20 14:12:19 +07:00
2017-12-18 16:24:56 -05:00
2018-06-28 13:43:30 -04:00
2018-09-24 20:35:44 -06:00

sapper-template-auth

A version of the default Sapper template that shows how auth can be done using Passport and JWT.

NOTE: this version is forked from the Rollup branch. Please follow the readme file in that branch for basic setup.

Auth

In this branch, the app/server.js and app/client.js files are modified to include setup for authentication. Note that most of the setup takes place in app/auth/setup.js.

Store

The server checks for a user, and if present, pushes it up to the client's store. Likewise, on login/signup, the user (signified as $user in HTML) is created and added to the store.

This allows you to do auth-specific HTML such as:

{#if $user}
	<Private/>
{:else}
	<Public/>
{/if}

JWT tokens

Please note, there are no back end sessions stored anywhere. Instead, the JWT token is stored on the client in a cookie, which is passed on each request. This can then be validated against a JWT_SECRET variable. In this app, for convenience, that variable is hard coded, but you MUST MAKE IT SECRET, likely as an environment variable.

Database

Also, for convenience, all data is stored in memory (or hard coded) in app/auth/db.js. You should absolutely lose this file and use an actual database to store your users.

Description
No description provided
Readme 1.1 MiB
Languages
JavaScript 66.4%
Svelte 19.9%
Shell 6.8%
HTML 4.4%
CSS 2.5%