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 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 = (await session.get('failed-login-attempts') || 0) as number
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', async (c) => {
64
- await c.get('session').deleteSession()
63
+ sessionRoutes.post('/logout', (c) => {
64
+ c.get('session').deleteSession()
65
65
  return c.redirect('/')
66
66
  })
67
67
 
68
- sessionRoutes.get('/', async (c) => {
68
+ sessionRoutes.get('/', (c) => {
69
69
  const session = c.get('session')
70
70
 
71
- const message = await session.get('message') || ''
72
- const error = await session.get('error') || ''
73
- const failedLoginAttempts = await session.get('failed-login-attempts')
74
- const email = await session.get('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">
@@ -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
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "hono-sessions",
5
- "version": "0.2.2",
5
+ "version": "0.2.3",
6
6
  "description": "Cookie-based sessions for Hono web framework",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -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
  }