mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 12:14:33 +01:00
24 lines
539 B
TypeScript
24 lines
539 B
TypeScript
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, '/')
|
|
},
|
|
})
|