You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/getting-started/session-management/login.mdx
+77Lines changed: 77 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -129,8 +129,47 @@ Just like in other frameworks, you can also pass a provider to the `signIn` func
129
129
</Code.Svelte>
130
130
<Code.Express>
131
131
132
+
132
133
The Express package runs server-side and therefore it doesn't make sense to create a "SignIn button component". However, to signin or signout with Express, send a request to the appropriate [REST API Endpoints](/reference/core/types#authaction) from your client (i.e. `/auth/signin`, `/auth/signout`, etc.).
133
134
135
+
To sign in users with Express, you can create a route that handles the sign-in logic. Here is an example:
136
+
137
+
```js filename="src/routes/auth.js"
138
+
constexpress=require("express")
139
+
constrouter=express.Router()
140
+
const { signIn } =require("../auth")
141
+
142
+
router.post("/auth/signin", async (req, res) => {
143
+
try {
144
+
awaitsignIn(req, res)
145
+
res.redirect("/dashboard")
146
+
} catch (error) {
147
+
res.status(500).send("Sign in failed")
148
+
}
149
+
})
150
+
151
+
module.exports= router
152
+
```
153
+
154
+
To sign out users with Express, you can create a route that handles the sign-out logic. Here is an example:
@@ -352,6 +391,44 @@ Client-side is a bit simpler as we just need to import a button `on:click` handl
352
391
353
392
The Express package runs server-side and therefore it doesn't make sense to create a "SignIn button component". However, to signin or signout with Express, send a request to the appropriate [REST API Endpoints](/reference/core/types#authaction) from your client (i.e. `/auth/signin`, `/auth/signout`, etc.).
354
393
394
+
To sign in users with Express, you can create a route that handles the sign-in logic. Here is an example:
395
+
396
+
```js filename="src/routes/auth.js"
397
+
constexpress=require("express")
398
+
constrouter=express.Router()
399
+
const { signIn } =require("../auth")
400
+
401
+
router.post("/auth/signin", async (req, res) => {
402
+
try {
403
+
awaitsignIn(req, res)
404
+
res.redirect("/dashboard")
405
+
} catch (error) {
406
+
res.status(500).send("Sign in failed")
407
+
}
408
+
})
409
+
410
+
module.exports= router
411
+
```
412
+
413
+
To sign out users with Express, you can create a route that handles the sign-out logic. Here is an example:
0 commit comments