replaced email with username

This commit is contained in:
Daniel
2023-07-08 14:05:43 +03:30
parent 3993615071
commit 97ca682c0a
32 changed files with 283 additions and 117 deletions
@@ -16,7 +16,7 @@ export default async function getCollection(userId: number) {
include: {
user: {
select: {
email: true,
username: true,
name: true,
},
},
@@ -42,7 +42,7 @@ export default async function postCollection(
color: collection.color,
members: {
create: collection.members.map((e) => ({
user: { connect: { email: e.user.email.toLowerCase() } },
user: { connect: { username: e.user.username.toLowerCase() } },
canCreate: e.canCreate,
canUpdate: e.canUpdate,
canDelete: e.canDelete,
@@ -57,7 +57,7 @@ export default async function postCollection(
include: {
user: {
select: {
email: true,
username: true,
name: true,
},
},
@@ -43,7 +43,7 @@ export default async function updateCollection(
isPublic: collection.isPublic,
members: {
create: collection.members.map((e) => ({
user: { connect: { email: e.user.email.toLowerCase() } },
user: { connect: { username: e.user.username.toLowerCase() } },
canCreate: e.canCreate,
canUpdate: e.canUpdate,
canDelete: e.canDelete,
@@ -58,7 +58,7 @@ export default async function updateCollection(
include: {
user: {
select: {
email: true,
username: true,
name: true,
id: true,
},
+5 -5
View File
@@ -1,13 +1,13 @@
import { prisma } from "@/lib/api/db";
export default async function getUser(
lookupEmail: string,
lookupUsername: string,
isSelf: boolean,
userEmail: string
username: string
) {
const user = await prisma.user.findUnique({
where: {
email: lookupEmail.toLowerCase(),
username: lookupUsername.toLowerCase(),
},
});
@@ -16,7 +16,7 @@ export default async function getUser(
if (
!isSelf &&
user?.isPrivate &&
!user.whitelistedUsers.includes(userEmail.toLowerCase())
!user.whitelistedUsers.includes(username.toLowerCase())
) {
return { response: "This profile is private.", status: 401 };
}
@@ -30,7 +30,7 @@ export default async function getUser(
// If user is requesting someone elses data
id: unsensitiveInfo.id,
name: unsensitiveInfo.name,
email: unsensitiveInfo.email,
username: unsensitiveInfo.username,
};
return { response: data || null, status: 200 };
+1 -1
View File
@@ -72,7 +72,7 @@ export default async function updateUser(
},
data: {
name: user.name,
email: user.email.toLowerCase(),
username: user.username.toLowerCase(),
isPrivate: user.isPrivate,
whitelistedUsers: user.whitelistedUsers,
},