Skip to content

Commit

Permalink
Merge branch 'main' into three-pane-okrs
Browse files Browse the repository at this point in the history
  • Loading branch information
simenheg committed Oct 12, 2023
2 parents 80c1988 + 6628837 commit 54a541f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class DomainWhitelistCollection {
this.collection = firestore.collection('domainWhitelist');
}

getDocumentById(id) {
return this.collection.doc(id).get();
listDocuments() {
return this.collection.listDocuments();
}
}

Expand Down
8 changes: 3 additions & 5 deletions functions/backend/utils/handleAccessRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ export const createAccessRequest = async (db, accessRequest) => {
return { code: 400, message: 'toaster.request.noEmail' };
}

const emailDomain = email.split('@')[1];
const emailDomain = email.split('@')[1].trim();
const domainWhitelistCollection = new DomainWhitelistCollection(db);
const usersCollection = new UsersCollection(db);

const domainWhitelistSnapshot = await domainWhitelistCollection.getDocumentById(
emailDomain
);
const whitelist = await domainWhitelistCollection.listDocuments();

if (domainWhitelistSnapshot.exists) {
if (whitelist.some((x) => x.id.trim() === emailDomain)) {
try {
await usersCollection.addDocument({ id: email, email });

Expand Down

0 comments on commit 54a541f

Please sign in to comment.