hono-sessions 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/esm/src/Middleware.js +1 -1
- package/package.json +1 -1
- package/script/src/Middleware.js +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ sessionRoutes.post('/login', async (c) => {
|
|
|
52
52
|
session.set('failed-login-attempts', null)
|
|
53
53
|
session.flash('message', 'Login Successful')
|
|
54
54
|
} else {
|
|
55
|
-
const failedLoginAttempts = (
|
|
55
|
+
const failedLoginAttempts = (session.get('failed-login-attempts') || 0) as number
|
|
56
56
|
session.set('failed-login-attempts', failedLoginAttempts + 1)
|
|
57
57
|
session.flash('error', 'Incorrect username or password')
|
|
58
58
|
}
|
|
@@ -60,18 +60,18 @@ sessionRoutes.post('/login', async (c) => {
|
|
|
60
60
|
return c.redirect('/')
|
|
61
61
|
})
|
|
62
62
|
|
|
63
|
-
sessionRoutes.post('/logout',
|
|
64
|
-
|
|
63
|
+
sessionRoutes.post('/logout', (c) => {
|
|
64
|
+
c.get('session').deleteSession()
|
|
65
65
|
return c.redirect('/')
|
|
66
66
|
})
|
|
67
67
|
|
|
68
|
-
sessionRoutes.get('/',
|
|
68
|
+
sessionRoutes.get('/', (c) => {
|
|
69
69
|
const session = c.get('session')
|
|
70
70
|
|
|
71
|
-
const message =
|
|
72
|
-
const error =
|
|
73
|
-
const failedLoginAttempts =
|
|
74
|
-
const email =
|
|
71
|
+
const message = session.get('message') || ''
|
|
72
|
+
const error = session.get('error') || ''
|
|
73
|
+
const failedLoginAttempts = session.get('failed-login-attempts')
|
|
74
|
+
const email = session.get('email')
|
|
75
75
|
|
|
76
76
|
return c.html(`<!DOCTYPE html>
|
|
77
77
|
<html lang="en">
|
package/esm/src/Middleware.js
CHANGED
|
@@ -79,7 +79,7 @@ export function sessionMiddleware(options) {
|
|
|
79
79
|
await store.createSession(sid, session.getCache());
|
|
80
80
|
setCookie(c, sessionCookieName, encryptionKey ? await encrypt(encryptionKey, sid) : sid, cookieOptions);
|
|
81
81
|
}
|
|
82
|
-
store instanceof CookieStore ? await store.persistSessionData(c, session.getCache()) : store.persistSessionData(sid, session.getCache());
|
|
82
|
+
store instanceof CookieStore ? await store.persistSessionData(c, session.getCache()) : await store.persistSessionData(sid, session.getCache());
|
|
83
83
|
if (session.getCache()._delete) {
|
|
84
84
|
store instanceof CookieStore ? await store.deleteSession(c) : await store.deleteSession(sid);
|
|
85
85
|
}
|
package/package.json
CHANGED
package/script/src/Middleware.js
CHANGED
|
@@ -85,7 +85,7 @@ function sessionMiddleware(options) {
|
|
|
85
85
|
await store.createSession(sid, session.getCache());
|
|
86
86
|
(0, deps_js_2.setCookie)(c, sessionCookieName, encryptionKey ? await (0, mod_js_1.encrypt)(encryptionKey, sid) : sid, cookieOptions);
|
|
87
87
|
}
|
|
88
|
-
store instanceof CookieStore_js_1.default ? await store.persistSessionData(c, session.getCache()) : store.persistSessionData(sid, session.getCache());
|
|
88
|
+
store instanceof CookieStore_js_1.default ? await store.persistSessionData(c, session.getCache()) : await store.persistSessionData(sid, session.getCache());
|
|
89
89
|
if (session.getCache()._delete) {
|
|
90
90
|
store instanceof CookieStore_js_1.default ? await store.deleteSession(c) : await store.deleteSession(sid);
|
|
91
91
|
}
|