Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: account type
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Aug 19, 2023
1 parent 1955250 commit d992d2a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pages/api/profiles/[username]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ export async function getUserApi(req, res, username, options = {}) {
]);
getProfile = getProfile[0];

const getUser = await User.findOne({ _id: new ObjectId(getProfile.user) });

delete getProfile.user;
getProfile = {
accountType: getUser.type,
...getProfile,
links: getProfile.links
.filter((link) => link.isEnabled)
Expand All @@ -106,6 +102,22 @@ export async function getUserApi(req, res, username, options = {}) {
})),
};

let getUser = {};
if (getProfile.user) {
getUser = await User.findOne({ _id: new ObjectId(getProfile.user) });

getProfile = {
...getProfile,
accountType: getUser.type || "free",
};
} else {
getProfile = {
...getProfile,
accountType: "free",
};
}
delete getProfile.user;

if (getProfile.events) {
let dateEvents = [];
const today = new Date();
Expand Down

0 comments on commit d992d2a

Please sign in to comment.