Skip to content

Commit

Permalink
Updates from airqstaging staging
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasTurner23 committed Feb 27, 2025
2 parents 0b04fcc + 98d483e commit 7da68b6
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion k8s/auth-service/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-auth-api
tag: prod-486fc5ca-1740492588
tag: prod-533e06c0-1740550034
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/auth-service/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-auth-api
tag: stage-967ec6d2-1740492484
tag: stage-c19b9d1b-1740578709
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/data-mgt/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-data-mgt-api
tag: prod-486fc5ca-1740492588
tag: prod-ce31cd3f-1740578785
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-registry/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-device-registry-api
tag: prod-486fc5ca-1740492588
tag: prod-ce31cd3f-1740578785
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/predict/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ images:
predictJob: eu.gcr.io/airqo-250220/airqo-predict-job
trainJob: eu.gcr.io/airqo-250220/airqo-train-job
predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality
tag: prod-486fc5ca-1740492588
tag: prod-ce31cd3f-1740578785
api:
name: airqo-prediction-api
label: prediction-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/spatial/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-spatial-api
tag: prod-486fc5ca-1740492588
tag: prod-ce31cd3f-1740578785
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
initContainer: eu.gcr.io/airqo-250220/airqo-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-redis
containers: eu.gcr.io/airqo-250220/airqo-workflows
tag: prod-486fc5ca-1740492588
tag: prod-ce31cd3f-1740578785
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
initContainer: eu.gcr.io/airqo-250220/airqo-stage-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-stage-redis
containers: eu.gcr.io/airqo-250220/airqo-stage-workflows
tag: stage-3aa81a24-1740490113
tag: stage-58e2cd39-1740493727
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
25 changes: 18 additions & 7 deletions src/auth-service/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,23 @@ const createUser = {
? defaultTenant
: req.query.tenant;

logObject("req.user.toAuthJSON()", req.user.toAuthJSON());
const token = req.user.toAuthJSON().token;
const userDetails = await req.user.toAuthJSON();
logObject("userDetails", userDetails);
const token = userDetails.token;
logger.info(`the user token after login with Google is : ${token}`);

// Update user fields
const currentDate = new Date();
try {
await UserModel(request.query.tenant) // Use the tenant from the request.
await UserModel(request.query.tenant)
.findOneAndUpdate(
{ _id: req.user._id }, // Access the correct user ID
{ _id: req.user._id },
{
$set: { lastLogin: currentDate, isActive: true },
$inc: { loginCount: 1 },
// Add any other updates as needed (e.g., verified)
// ...(req.user.analyticsVersion !== 3 && req.user.verified === false ? { $set: { verified: true } } : {}), // Example (if you have these fields)
...(req.user.analyticsVersion !== 3 && req.user.verified === false
? { $set: { verified: true } }
: {}),
},
{ new: true, upsert: false, runValidators: true }
)
Expand All @@ -395,8 +397,17 @@ const createUser = {
secure: true, // Enable if using HTTPS
});

if (constants.ENVIRONMENT === "STAGING ENVIRONMENT") {
// Create a temporary, non-httpOnly cookie for debugging:
res.cookie("temp_access_token", token, {
httpOnly: false, // Set to false for debugging
secure: true, // But keep secure: true (if using HTTPS)
// maxAge: 60 * 1000, //Expires in 60 seconds.
});
}

res.redirect(
`${constants.GMAIL_VERIFICATION_SUCCESS_REDIRECT}?success=google`
`${constants.GMAIL_VERIFICATION_SUCCESS_REDIRECT}/xyz/Home?success=google`
);

/***
Expand Down
6 changes: 3 additions & 3 deletions src/auth-service/middleware/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,16 @@ const useGoogleStrategy = (tenant, req, res, next) =>
}
);
cb(null, user);
//return next();
return next();
} else {
// profilePicture: profile._json.picture,
const responseFromRegisterUser = await UserModel(tenant).register(
{
google_id: profile._json.sub,
firstName: profile._json.given_name,
lastName: profile._json.family_name,
email: profile._json.email,
userName: profile._json.email,
profilePicture: profile._json.picture,
website: profile._json.hd,
password: accessCodeGenerator.generate(
constants.RANDOM_PASSWORD_CONFIGURATION(constants.TOKEN_LENGTH)
Expand Down Expand Up @@ -518,7 +518,7 @@ const useGoogleStrategy = (tenant, req, res, next) =>
}
cb(null, user);

// return next();
return next();
}
}
} catch (error) {
Expand Down
10 changes: 9 additions & 1 deletion src/auth-service/utils/token.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,21 @@ let blacklistQueue = async.queue(async (task, callback) => {
logObject(`🤩🤩 Published IP ${ip} to the "ip-address" topic.`);
// logger.info(`🤩🤩 Published IP ${ip} to the "ip-address" topic.`);
callback();
})
.catch((error) => {
logObject("kafka producer send error", error);
callback();
});
await kafkaProducer.disconnect();
await kafkaProducer.disconnect().catch((error) => {
logObject("kafka producer disconnect error", error);
});
// callback();
} catch (error) {
logObject("error", error);
// logger.error(
// `🐛🐛 KAFKA Producer Internal Server Error --- IP_ADDRESS: ${ip} --- ${error.message}`
// );
callback();
}
}, 1); // Limit the number of concurrent tasks to 1

Expand Down

0 comments on commit 7da68b6

Please sign in to comment.