xonecas.io
4515
Nr

node-react-typescript-boilerplate / commit 3e9255a

Adds cookie fix and some styles

Sean2023-01-10 3e9255a601f09b6b8cc06e9a7ac102e6f584deab parent cb40778

15 files changed

client/build/asset-manifest.json+5−5
@@ -1,15 +1,15 @@
11 {
22 "main.css": "/static/css/main.c8758b99.chunk.css",
3- "main.js": "/static/js/main.98616005.chunk.js",
4- "main.js.map": "/static/js/main.98616005.chunk.js.map",
3+ "main.js": "/static/js/main.e9384b50.chunk.js",
4+ "main.js.map": "/static/js/main.e9384b50.chunk.js.map",
55 "runtime~main.js": "/static/js/runtime~main.a084bf6b.js",
66 "runtime~main.js.map": "/static/js/runtime~main.a084bf6b.js.map",
7- "static/js/2.5910c8a4.chunk.js": "/static/js/2.5910c8a4.chunk.js",
8- "static/js/2.5910c8a4.chunk.js.map": "/static/js/2.5910c8a4.chunk.js.map",
7+ "static/js/2.879bba26.chunk.js": "/static/js/2.879bba26.chunk.js",
8+ "static/js/2.879bba26.chunk.js.map": "/static/js/2.879bba26.chunk.js.map",
99 "static/js/3.5042479d.chunk.js": "/static/js/3.5042479d.chunk.js",
1010 "static/js/3.5042479d.chunk.js.map": "/static/js/3.5042479d.chunk.js.map",
1111 "index.html": "/index.html",
12- "precache-manifest.b8f5f3c4e8c47fd19ce3366264e22536.js": "/precache-manifest.b8f5f3c4e8c47fd19ce3366264e22536.js",
12+ "precache-manifest.8a877dd3f9a99ffb1afdaacef9a3a20f.js": "/precache-manifest.8a877dd3f9a99ffb1afdaacef9a3a20f.js",
1313 "service-worker.js": "/service-worker.js",
1414 "static/css/main.c8758b99.chunk.css.map": "/static/css/main.c8758b99.chunk.css.map"
1515 }
client/build/index.html+1−1
@@ -1 +1 @@
1-<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><link href="/static/css/main.c8758b99.chunk.css" rel="stylesheet"></head><body><noscript>You nee …
1+<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><link href="/static/css/main.c8758b99.chunk.css" rel="stylesheet"></head><body><noscript>You nee …
client/build/precache-manifest.8a877dd3f9a99ffb1afdaacef9a3a20f.js+6−6
@@ -1,26 +1,26 @@
11 self.__precacheManifest = [
22 {
3- "revision": "12d039f054c9a0a1131a",
3+ "revision": "ed4dba4df6189caf6a8d",
44 "url": "/static/css/main.c8758b99.chunk.css"
55 },
66 {
7- "revision": "12d039f054c9a0a1131a",
8- "url": "/static/js/main.98616005.chunk.js"
7+ "revision": "ed4dba4df6189caf6a8d",
8+ "url": "/static/js/main.e9384b50.chunk.js"
99 },
1010 {
1111 "revision": "13810285cfe83a0e3f7c",
1212 "url": "/static/js/runtime~main.a084bf6b.js"
1313 },
1414 {
15- "revision": "56867d352761e5e7c360",
16- "url": "/static/js/2.5910c8a4.chunk.js"
15+ "revision": "7035108e780caa696b6e",
16+ "url": "/static/js/2.879bba26.chunk.js"
1717 },
1818 {
1919 "revision": "19ddbbd90272197c9edd",
2020 "url": "/static/js/3.5042479d.chunk.js"
2121 },
2222 {
23- "revision": "bc8cbed73c77c72a65e58df629c58d02",
23+ "revision": "7b6dc1c13a2cb224985413c7da4d5da6",
2424 "url": "/index.html"
2525 }
2626 ];
client/build/service-worker.js+1−1
@@ -14,7 +14,7 @@
1414 importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");
1515
1616 importScripts(
17- "/precache-manifest.b8f5f3c4e8c47fd19ce3366264e22536.js"
17+ "/precache-manifest.8a877dd3f9a99ffb1afdaacef9a3a20f.js"
1818 );
1919
2020 workbox.clientsClaim();
client/build/static/js/2.5910c8a4.chunk.js.map+0−1
@@ -1 +0,0 @@
1-{"version":3,"sources":["../node_modules/axios/lib/utils.js","../node_modules/react/index.js","../node_modules/axios/lib/core/AxiosError.js","../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../node_modules/babel-preset-react-app/node_modules/@bab …
client/build/static/js/2.879bba26.chunk.js+2−2
@@ -1,2 +1,2 @@
1-(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[function(e,t,n){"use strict";(function(e){var r,a=n(9),o=Object.prototype.toString,i=Object.getPrototypeOf,l=(r=Object.create(null),function(e){var t=o.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())}),u=function(e){return e=e.toLowerCase(),function(t){return l(t)===e}},s=function(e){return function(t){return typeof t===e}},c=Array.isArray,f=s("undefined");var d=u("ArrayBuffer");var p=s("string"),h=s("function"),m=s("number"),g=fun …
2-//# sourceMappingURL=2.5910c8a4.chunk.js.map
1+(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[function(e,t,n){"use strict";(function(e){var r,a=n(9),o=Object.prototype.toString,i=Object.getPrototypeOf,l=(r=Object.create(null),function(e){var t=o.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())}),u=function(e){return e=e.toLowerCase(),function(t){return l(t)===e}},s=function(e){return function(t){return typeof t===e}},c=Array.isArray,f=s("undefined");var d=u("ArrayBuffer");var p=s("string"),h=s("function"),m=s("number"),g=fun …
2+//# sourceMappingURL=2.879bba26.chunk.js.map
client/build/static/js/2.879bba26.chunk.js.map+1−0
@@ -0,0 +1 @@
1+{"version":3,"sources":["../node_modules/axios/lib/utils.js","../node_modules/react/index.js","../node_modules/axios/lib/core/AxiosError.js","../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../node_modules/babel-preset-react-app/node_modules/@bab …
client/build/static/js/main.98616005.chunk.js+0−2
@@ -1,2 +0,0 @@
1-(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{21:function(e,n,t){e.exports=t(37)},29:function(e,n,t){},37:function(e,n,t){"use strict";t.r(n);var a,l,o=t(1),r=t.n(o),c=t(15),u=t.n(c),i=(t(29),t(5)),s=t(10),g=t.n(s),m=t(6),p=t(3),d=t(39);function f(e){var n=e.initialMode,t=Object(o.useState)(n),a=Object(p.a)(t,2),l=a[0],c=a[1],u=Object(o.useState)(""),i=Object(p.a)(u,2),s=i[0],g=i[1],m=Object(o.useState)(""),f=Object(p.a)(m,2),E=f[0],v=f[1],j=Object(o.useState)(""),O=Object(p.a)(j,2),C …
2-//# sourceMappingURL=main.98616005.chunk.js.map
client/build/static/js/main.98616005.chunk.js.map+0−1
@@ -1 +0,0 @@
1-{"version":3,"sources":["components/login/index.tsx","App.tsx","reportWebVitals.ts","index.tsx"],"names":["LoginForm","_ref","initialMode","_useState","useState","_useState2","Object","slicedToArray","mode","setMode","_useState3","_useState4","email","setEmail","_useState5","_useState6","name","setName","_useState7","_useState8","password","setPassword","handleSubmit","e","preventDefault","axios","post","concat","headers","Content-Type","then","response","console","log","catch","error","react_de …
client/build/static/js/main.e9384b50.chunk.js+2−0
@@ -0,0 +1,2 @@
1+(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{21:function(e,n,t){e.exports=t(37)},29:function(e,n,t){},37:function(e,n,t){"use strict";t.r(n);var a,l,r,o,c,i=t(1),u=t.n(i),m=t(14),d=t.n(m),s=(t(29),t(5)),p=t(15),g=t.n(p),f=t(6),b=t(3),E=t(39);function h(e){var n=e.initialMode,t=Object(i.useState)(n),a=Object(b.a)(t,2),l=a[0],r=a[1],o=Object(i.useState)(""),c=Object(b.a)(o,2),m=c[0],d=c[1],s=Object(i.useState)(""),p=Object(b.a)(s,2),g=p[0],f=p[1],h=Object(i.useState)(""),j=Object(b.a)( …
2+//# sourceMappingURL=main.e9384b50.chunk.js.map
client/build/static/js/main.e9384b50.chunk.js.map+1−0
@@ -0,0 +1 @@
1+{"version":3,"sources":["components/login/index.tsx","App.tsx","reportWebVitals.ts","index.tsx"],"names":["LoginForm","_ref","initialMode","_useState","useState","_useState2","Object","slicedToArray","mode","setMode","_useState3","_useState4","email","setEmail","_useState5","_useState6","name","setName","_useState7","_useState8","password","setPassword","handleSubmit","e","preventDefault","axios","post","concat","headers","Content-Type","then","response","console","log","catch","error","react_de …
client/src/components/login/index.tsx+32−9
@@ -33,7 +33,7 @@ export default function LoginForm({
3333 )
3434 .then((response) => {
3535 console.log(response);
36- // Mark the user as logged in? if in the correct mode.
36+ // Redirect the user back
3737 })
3838 .catch((error) => {
3939 console.log(error);
@@ -44,7 +44,7 @@ export default function LoginForm({
4444 return (
4545 <StyledLoginForm onSubmit={(e) => handleSubmit(e)}>
4646 <h1>{mode.charAt(0).toLocaleUpperCase() + mode.slice(1)}</h1>
47- <p>
47+ <StyledSmallText>
4848 Or{" "}
4949 {mode === "login" && (
5050 <a
@@ -69,7 +69,7 @@ export default function LoginForm({
6969 </a>
7070 )}{" "}
7171 instead.
72- </p>
72+ </StyledSmallText>
7373 <p>
7474 <label>Email:</label>
7575 </p>
@@ -96,13 +96,13 @@ export default function LoginForm({
9696 <label>Password:</label>
9797 </p>
9898 <StyledLoginFromInputs
99- type="text"
99+ type="password"
100100 onChange={(e) => setPassword(e.target.value)}
101101 value={password}
102102 />
103- <p>
104- <button onClick={(e) => handleSubmit(e)}>Submit</button>
105- </p>
103+ <StyledButtonContainer>
104+ <StyledButton onClick={(e) => handleSubmit(e)}>Submit</StyledButton>
105+ </StyledButtonContainer>
106106 </StyledLoginForm>
107107 );
108108 }
@@ -117,12 +117,35 @@ const StyledLoginForm = styled.form`
117117 `;
118118
119119 const StyledLoginFromInputs = styled.input`
120- padding: .25em 0;
120+ font-family: Consolas, 'Courier New', monospace;
121+ padding: .25em .25em .3em;
121122 margin: 0 0 1em 0;
122123 border: 1px solid #ddd;
123- border-radius: 2px;
124+ border-radius: 4px;
125+ width: 100%;
124126
125127 &:focus {
126128 outline: 0;
127129 }
128130 `;
131+
132+const StyledSmallText = styled.h3`
133+ color: #aaa;
134+ font-size: 12px;
135+ font-weight: 400;
136+ padding: .5em 0 1em;
137+`;
138+
139+const StyledButtonContainer = styled.div`
140+ display: flex;
141+ justify-content: end;
142+`;
143+
144+const StyledButton = styled.button`
145+ margin: 1em 0 0 0;
146+ padding: .25em .5em;
147+ border: 1px solid #ddd;
148+ border-radius: 4px;
149+ background-color: #111;
150+ color: #eee;
151+`;
dist/auth/index.js+1−1
@@ -19,6 +19,7 @@ function register(ctx, next) {
1919 const user = yield index_1.prisma.user.create({
2020 data: data,
2121 });
22+ ctx.cookies.set("logged_user", user.email, { httpOnly: false });
2223 ctx.status = 201;
2324 ctx.response.body = user;
2425 next();
@@ -49,7 +50,6 @@ function login(ctx, next) {
4950 ctx.response.body = { error: "No user with specified email." };
5051 }
5152 if (data.password === (user === null || user === void 0 ? void 0 : user.password)) {
52- // We should set a cookie with something here...
5353 ctx.cookies.set("logged_user", user === null || user === void 0 ? void 0 : user.email, { httpOnly: false });
5454 ctx.status = 200;
5555 ctx.response.body = user;
prisma/dev.db+0−0
Binary file, not shown.
src/auth/index.ts+1−1
@@ -9,6 +9,7 @@ export async function register(ctx: Koa.ParameterizedContext, next: Koa.Next) {
99 data: data,
1010 });
1111
12+ ctx.cookies.set("logged_user", user.email, { httpOnly: false });
1213 ctx.status = 201;
1314 ctx.response.body = user;
1415
@@ -38,7 +39,6 @@ export async function login(ctx: Koa.ParameterizedContext, next: Koa.Next) {
3839 }
3940
4041 if (data.password === user?.password) {
41- // We should set a cookie with something here...
4242 ctx.cookies.set("logged_user", user?.email, { httpOnly: false });
4343 ctx.status = 200;
4444 ctx.response.body = user;