added update account functionality

This commit is contained in:
Daniel
2023-05-20 22:55:00 +03:30
parent e3862188de
commit 0ce97f0b64
13 changed files with 345 additions and 61 deletions
+10 -12
View File
@@ -12,21 +12,19 @@ export default async function (lookupEmail: string, isSelf: boolean) {
},
});
if (!user) return { response: "User not found." || null, status: 404 };
const { password, ...unsensitiveInfo } = user;
const data = isSelf
? {
// If user is requesting its data
id: user?.id,
name: user?.name,
email: user?.email,
}
? // If user is requesting its own data
unsensitiveInfo
: {
// If user is requesting someone elses data
id: user?.id,
name: user?.name,
email: user?.email,
id: unsensitiveInfo.id,
name: unsensitiveInfo.name,
email: unsensitiveInfo.email,
};
const statusCode = user?.id ? 200 : 404;
return { response: data || null, status: statusCode };
return { response: data || null, status: 200 };
}