cloudflare-auth
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -12,7 +12,9 @@ import { html, htmlResponse } from 'cloudflare-htmx'; | ||
html` | ||
<form method="post" action="/dash"> | ||
<h1>Protected Route</h1> | ||
<button type="submit">Logout</button> | ||
</form> | ||
<div class="text-center pt-10 h-screen"> | ||
<form method="post" action="/dash"> | ||
<h1 class="text-3xl text-primary mb-4">This is a protected route</h1> | ||
<button class="btn btn-secondary w-96" type="submit">Logout</button> | ||
</form> | ||
</div> | ||
` | ||
); |
@@ -13,3 +13,2 @@ import { html, htmlResponse } from 'cloudflare-htmx'; | ||
name="email" | ||
data-cy="email" | ||
class="input text-xl bg-neutral h-14 pl-10 pt-2 pb-2 w-full md:w-96" | ||
@@ -16,0 +15,0 @@ type="email" |
@@ -1,5 +0,5 @@ | ||
import { login, Env } from 'cloudflare-auth'; | ||
import { generateToken, Env } from 'cloudflare-auth'; | ||
import { sendEmail } from '@lib/email'; | ||
import Toast from '@components/Toast'; | ||
import { htmlResponse } from 'cloudflare-htmx'; | ||
import { html, htmlResponse } from 'cloudflare-htmx'; | ||
@@ -13,8 +13,7 @@ export const onRequestPost: PagesFunction<Env> = async ({ request, env }) => { | ||
} | ||
const token = await login(email, env); | ||
const token = await generateToken(email, env); | ||
const magicLink = `${url.origin}/verify?token=${token}`; | ||
try { | ||
await sendEmail(email, magicLink); | ||
console.log('here'); | ||
return htmlResponse(Toast('Check your email for magic link.')); | ||
return htmlResponse(Toast(html` <a class="link text-primary" href="${magicLink}">Click here to login</a> `, 'alert-success', false)); | ||
} catch { | ||
@@ -21,0 +20,0 @@ return htmlResponse(Toast('Magic link failed to send!', 'alert-failure')); |
import { html } from 'cloudflare-htmx'; | ||
export default (message: string, alertClass = 'alert-success') => { | ||
export default (message: string, alertClass = 'alert-success', fadeOut = true) => { | ||
return html` | ||
<div class="toast toast-end w-full md:w-76 mt-10" _="on load wait 3s add .fadeOut wait 1s remove me"> | ||
<div class="toast toast-end w-full md:w-76 mt-10" ${fadeOut ? `_="on load wait 3s add .fadeOut wait 1s remove me"` : ''}> | ||
<div class="alert ${alertClass} justify-center"> | ||
@@ -7,0 +7,0 @@ <span class="text-lg font-bold"> ${message} </span> |
{ | ||
"name": "cloudflare-auth", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "JWT implementation for Cloudflare using D1", | ||
"main": "index.ts", | ||
"main": "src/index.ts", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
346360
31
10112
1
120