File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,37 @@ export const handle = sequence(
89
89
);
90
90
```
91
91
92
+ Then, add a login handler ` src/routes/auth/[provider]/+server.ts ` :
93
+
94
+ ``` ts
95
+ import { redirect , type RequestEvent } from ' @sveltejs/kit' ;
96
+
97
+ export const GET = async (event : RequestEvent ) => {
98
+ const { request } = event ;
99
+ const provider = event .params .provider ?? ' github' ;
100
+ return await event .locals .auth .authenticate (event , provider , {
101
+ successRedirect: ' /dashboard' ,
102
+ failureRedirect: ' /error'
103
+ });
104
+ };
105
+ ```
106
+
107
+ Finally, add a callback handler ` src/routes/auth/[provider]/callback/+server.ts.ts ` :
108
+
109
+ ``` ts
110
+ // same as before...
111
+ import type { RequestEvent } from ' @sveltejs/kit' ;
112
+
113
+ export const GET = async (event : RequestEvent ) => {
114
+ const provider = event .params .provider ?? ' github' ;
115
+
116
+ return await event .locals .auth .authenticate (event , provider , {
117
+ successRedirect: ' /dashboard' ,
118
+ failureRedirect: ' /error'
119
+ });
120
+ };
121
+ ```
122
+
92
123
## Advanced Usage
93
124
94
125
### Typescript
You can’t perform that action at this time.
0 commit comments