aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/GeneralGoogleManager.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-06-04 21:32:34 -0400
committerbobzel <zzzman@gmail.com>2025-06-04 21:32:34 -0400
commitf7cb0dcebb0514cf38f8a7e635ec9959c196145a (patch)
treee352a223a692d922e9f9780fd069d786f4c3bec1 /src/server/ApiManagers/GeneralGoogleManager.ts
parent8d424c8cb4d178d5fb92b6543d63fa409eb6430b (diff)
cleaned up getting client id/secret for google. fixed final message after going through authentication process.
Diffstat (limited to 'src/server/ApiManagers/GeneralGoogleManager.ts')
-rw-r--r--src/server/ApiManagers/GeneralGoogleManager.ts39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/server/ApiManagers/GeneralGoogleManager.ts b/src/server/ApiManagers/GeneralGoogleManager.ts
index 59d066934..693b17779 100644
--- a/src/server/ApiManagers/GeneralGoogleManager.ts
+++ b/src/server/ApiManagers/GeneralGoogleManager.ts
@@ -96,25 +96,26 @@ export default class GeneralGoogleManager extends ApiManager {
register({
method: Method.GET,
subscription: '/refreshGoogle',
- secureHandler: async ({ user, req, res }) => {
- const code = req.query.code as string;
-
- try {
- const enriched = await GoogleApiServerUtils.processNewUser(user.id, code);
-
- if (enriched.refresh_token) {
- if (enriched.refresh_token) {
- user.googleToken = enriched.refresh_token;
- await user.save();
- } else {
- console.warn('No refresh token returned');
- }
- }
- } catch (err) {
- console.error('Failed to process Google code:', err);
- res.status(500).send('Error linking Google account');
- }
- },
+ secureHandler: async ({ user, req, res }) =>
+ new Promise<void>(resolve =>
+ GoogleApiServerUtils.processNewUser(user.id, req.query.code as string)
+ .then(enriched => {
+ if (enriched.refresh_token) {
+ if (enriched.refresh_token) {
+ user.googleToken = enriched.refresh_token;
+ user.save();
+ } else {
+ console.warn('No refresh token returned');
+ }
+ }
+ res.status(200).send('Google account linked successfully!');
+ })
+ .catch(err => {
+ console.error('Failed to process Google code:', err);
+ res.status(500).send('Error linking Google account');
+ })
+ .finally(resolve)
+ ),
});
}
}