easrng-signinwithvaltowndemo.web.val.run
Readme

An example of how to add authentication backed by val.town accounts to a val. Open

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsx jsx */
/** @jsxFrag Fragment */
import {
createContext,
type FC,
Fragment,
jsx,
type PropsWithChildren,
useContext,
} from "https://deno.land/x/hono@v4.0.10/jsx/index.ts";
import { Hono } from "https://deno.land/x/hono@v4.0.10/mod.ts";
import { type AuthenticatedRequest, signInWithValTown, type User } from "https://esm.town/v/easrng/signInWithValTown";
const app = new Hono<{ Variables: { user: User } }>();
app.use((c, next) => {
c.set("user", (c.req.raw as AuthenticatedRequest).user);
return next();
});
app.get((c) => {
const user = c.get("user");
return c.html(
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>@easrng/signInWithValTown demo</title>
<style
dangerouslySetInnerHTML={{
__html: String.raw`
* {
box-sizing: border-box;
}
body {
margin: 0 auto;
width: fit-content;
max-width: 25rem;
width: 100%;
padding: 1rem;
}
.user {
display: grid;
grid-template-areas: "... as"
"pfp name"
"... bio"
"... signout";
grid-template-columns: 2rem 1fr;
padding: 0.5rem 0.75rem 0.75rem;
border-radius: 0.5rem;
border: 1px solid GrayText;
margin: 1rem 0;
grid-gap: 0rem 0.5rem;
line-height: 1.75;
}
.pfp {
width: 2rem;
grid-area: pfp;
border-radius: 50%;
align-self: center;
aspect-ratio: 1 / 1;
}
.username {
color: inherit;
text-decoration: none;
font-weight: bold;
align-self: center;
grid-area: name;
}
.bio {
grid-area: bio;
margin: 0;
}
html {
color-scheme: light dark;
font-family: system-ui, sans-serif;
}
.as {
grid-area: as;
font-size: 0.75rem;
text-transform: uppercase;
color: GrayText;
line-height: 1;
margin-top: 0.5rem;
}
.signout {
grid-area: signout;
margin: 0.5rem 0 0;
display: flex;
align-items: center;
justify-content: end;
}
button {
height: 1.75rem;
font-size: 0.9rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: fit-content;
border: 1px solid transparent;
padding: 0 0.5rem;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 12, 2024