File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ import { createResponse } from "./utils";
44
55const DURABLE_OBJECT_ID = 'sql-durable-object' ;
66
7- export default class AuthEntrypoint extends WorkerEntrypoint {
7+ interface Env {
8+ DATABASE_DURABLE_OBJECT : DurableObjectNamespace ;
9+ }
10+
11+ export default class AuthEntrypoint extends WorkerEntrypoint < Env > {
812 private stub : any ;
913
1014 // Currently, entrypoints without a named handler are not supported
@@ -44,4 +48,19 @@ export default class AuthEntrypoint extends WorkerEntrypoint {
4448 success : true ,
4549 } ) , undefined , 200 ) ;
4650 }
51+
52+ /**
53+ * Checks if a session is valid by checking if the session token exists and is not deleted
54+ * @param sessionToken
55+ * @returns
56+ */
57+ async isSessionValid ( sessionToken : string ) {
58+ let result = await this . stub . executeExternalQuery (
59+ `SELECT * FROM auth_sessions
60+ WHERE session_token = ?
61+ AND deleted_at IS NULL` ,
62+ [ sessionToken ]
63+ ) ;
64+ return result . result . length > 0 ;
65+ }
4766}
You can’t perform that action at this time.
0 commit comments