IO-710 Export Log page & insert actions on export

This commit is contained in:
Patrick Fic
2021-04-21 14:31:40 -07:00
parent 6d9576b9a4
commit 09e1ab7f83
38 changed files with 653 additions and 180 deletions

View File

@@ -7,40 +7,29 @@ exports.processSignUp = functions.auth.user().onCreate((user) => {
// Check if user meets role criteria:
// Your custom logic here: to decide what roles and other `x-hasura-*` should the user get
let customClaims;
// if (user.email && user.email.indexOf("@thinkimex.com") !== -1) {
// customClaims = {
// "https://hasura.io/jwt/claims": {
// "x-hasura-default-role": "admin",
// "x-hasura-allowed-roles": ["user", "admin"],
// "x-hasura-user-id": user.uid,
// },
// };
// } else {
customClaims = {
"https://hasura.io/jwt/claims": {
"x-hasura-default-role": "user",
"x-hasura-allowed-roles": ["user"],
"x-hasura-user-id": user.uid,
},
};
//}
//Removed for now - outbound connections are not free on firebase.
// fetch(GRAPHQL_ENDPOINT, {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// Accept: "application/json",
// "x-hasura-admin-secret": HASURA_SECRET_ADMIN_KEY
// },
// body: JSON.stringify({
// query: UPSERT_USER,
// variables: { authEmail: user.email, authToken: user.uid }
// })
// });
if (user.email && user.email.indexOf("@admin.imex.online") !== -1) {
customClaims = {
"https://hasura.io/jwt/claims": {
"x-hasura-default-role": "admin",
"x-hasura-allowed-roles": ["user", "admin"],
"x-hasura-user-id": user.uid,
},
};
} else {
customClaims = {
"https://hasura.io/jwt/claims": {
"x-hasura-default-role": "user",
"x-hasura-allowed-roles": ["user"],
"x-hasura-user-id": user.uid,
},
};
}
// Set custom user claims on this newly created user.
return admin.auth().setCustomUserClaims(user.uid, customClaims);
//exports.test = functions.auth.
// .then(() => {
// // Update real-time database to notify client to force refresh.
// const metadataRef = admin.database().ref("metadata/" + user.uid);