-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8304 from romayalon/romy-accounts-id-cache
NC | Accounts ID cache addition
- Loading branch information
Showing
8 changed files
with
128 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Copyright (C) 2024 NooBaa */ | ||
'use strict'; | ||
|
||
const mongo_utils = require('../util/mongo_utils'); | ||
|
||
/** | ||
* generate_id will generate an id that we use to identify entities (such as account, bucket, etc.). | ||
*/ | ||
// TODO: | ||
// - reuse this function in NC NSFS where we used the mongo_utils module | ||
// - this function implantation should be db_client.new_object_id(), | ||
// but to align with manage nsfs we won't change it now | ||
function generate_id() { | ||
return mongo_utils.mongoObjectId(); | ||
} | ||
|
||
/** | ||
* check_root_account_owns_user checks if an account is owned by root account | ||
* @param {object} root_account | ||
* @param {object} account | ||
*/ | ||
function check_root_account_owns_user(root_account, account) { | ||
if (account.owner === undefined) return false; | ||
return root_account._id === account.owner; | ||
} | ||
|
||
// EXPORTS | ||
exports.generate_id = generate_id; | ||
exports.check_root_account_owns_user = check_root_account_owns_user; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.