mirror of
https://github.com/ArthurDanjou/spanish-learner.git
synced 2026-01-14 12:14:39 +01:00
Initial commit
This commit is contained in:
23
server/routes/auth/google.get.ts
Normal file
23
server/routes/auth/google.get.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export default oauth.googleEventHandler({
|
||||
config: {
|
||||
authorizationParams: {
|
||||
access_type: 'offline',
|
||||
},
|
||||
},
|
||||
async onSuccess(event, { user }) {
|
||||
await setUserSession(event, {
|
||||
user: {
|
||||
name: user.name,
|
||||
imageUrl: user.picture,
|
||||
email: user.email,
|
||||
},
|
||||
})
|
||||
|
||||
return sendRedirect(event, '/')
|
||||
},
|
||||
// Optional, will return a json error and 401 status code by default
|
||||
onError(event, error) {
|
||||
console.error('Google OAuth error:', error)
|
||||
return sendRedirect(event, '/')
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user