Release 2025-05-23-nwlb
This commit is contained in:
@@ -29,7 +29,7 @@ npm run db-fill-clean
|
|||||||
|
|
||||||
Now open the [.env](web/.env) file and fill in the missing values.
|
Now open the [.env](web/.env) file and fill in the missing values.
|
||||||
|
|
||||||
> Default users are created with tokens: `admin`, `verifier`, `verified`, `normal` (configurable via env vars)
|
> Default users are created with tokens: `admin`, `moderator`, `verified`, `normal` (configurable via env vars)
|
||||||
|
|
||||||
### Running the project
|
### Running the project
|
||||||
|
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ All commands are run from the root of the project, from a terminal:
|
|||||||
|
|
||||||
> **Note**: `db-fill` and `db-fill-clean` support the `-- --services=n` flag, where n is the number of fake services to add. It defaults to 10. For example, `npm run db-fill -- --services=5` will add 5 fake services.
|
> **Note**: `db-fill` and `db-fill-clean` support the `-- --services=n` flag, where n is the number of fake services to add. It defaults to 10. For example, `npm run db-fill -- --services=5` will add 5 fake services.
|
||||||
|
|
||||||
> **Note**: `db-fill` and `db-fill-clean` create default users with tokens: `admin`, `verifier`, `verified`, `normal` (override with `DEV_*****_USER_SECRET_TOKEN` env vars)
|
> **Note**: `db-fill` and `db-fill-clean` create default users with tokens: `admin`, `moderator`, `verified`, `normal` (override with `DEV_*****_USER_SECRET_TOKEN` env vars)
|
||||||
|
|||||||
@@ -131,11 +131,11 @@ export default defineConfig({
|
|||||||
min: 1,
|
min: 1,
|
||||||
default: 'admin',
|
default: 'admin',
|
||||||
}),
|
}),
|
||||||
DEV_VERIFIER_USER_SECRET_TOKEN: envField.string({
|
DEV_MODERATOR_USER_SECRET_TOKEN: envField.string({
|
||||||
context: 'server',
|
context: 'server',
|
||||||
access: 'secret',
|
access: 'secret',
|
||||||
min: 1,
|
min: 1,
|
||||||
default: 'verifier',
|
default: 'moderator',
|
||||||
}),
|
}),
|
||||||
DEV_VERIFIED_USER_SECRET_TOKEN: envField.string({
|
DEV_VERIFIED_USER_SECRET_TOKEN: envField.string({
|
||||||
context: 'server',
|
context: 'server',
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
Manully edited to be a rename migration.
|
||||||
|
*/
|
||||||
|
-- AlterEnum
|
||||||
|
BEGIN;
|
||||||
|
ALTER TYPE "AccountStatusChange" RENAME VALUE 'VERIFIER_TRUE' TO 'MODERATOR_TRUE';
|
||||||
|
ALTER TYPE "AccountStatusChange" RENAME VALUE 'VERIFIER_FALSE' TO 'MODERATOR_FALSE';
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "User"
|
||||||
|
RENAME COLUMN "verifier" TO "moderator"
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ enum AccountStatusChange {
|
|||||||
ADMIN_FALSE
|
ADMIN_FALSE
|
||||||
VERIFIED_TRUE
|
VERIFIED_TRUE
|
||||||
VERIFIED_FALSE
|
VERIFIED_FALSE
|
||||||
VERIFIER_TRUE
|
MODERATOR_TRUE
|
||||||
VERIFIER_FALSE
|
MODERATOR_FALSE
|
||||||
SPAMMER_TRUE
|
SPAMMER_TRUE
|
||||||
SPAMMER_FALSE
|
SPAMMER_FALSE
|
||||||
}
|
}
|
||||||
@@ -464,7 +464,7 @@ model User {
|
|||||||
spammer Boolean @default(false)
|
spammer Boolean @default(false)
|
||||||
verified Boolean @default(false)
|
verified Boolean @default(false)
|
||||||
admin Boolean @default(false)
|
admin Boolean @default(false)
|
||||||
verifier Boolean @default(false)
|
moderator Boolean @default(false)
|
||||||
verifiedLink String?
|
verifiedLink String?
|
||||||
secretTokenHash String @unique
|
secretTokenHash String @unique
|
||||||
/// Computed via trigger. Do not update through prisma.
|
/// Computed via trigger. Do not update through prisma.
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ BEGIN
|
|||||||
VALUES (NEW.id, 'ACCOUNT_STATUS_CHANGE', status_change);
|
VALUES (NEW.id, 'ACCOUNT_STATUS_CHANGE', status_change);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Check for verifier status change
|
-- Check for moderator status change
|
||||||
IF OLD.verifier IS DISTINCT FROM NEW.verifier THEN
|
IF OLD.moderator IS DISTINCT FROM NEW.moderator THEN
|
||||||
IF NEW.verifier = true THEN
|
IF NEW.moderator = true THEN
|
||||||
status_change := 'VERIFIER_TRUE';
|
status_change := 'MODERATOR_TRUE';
|
||||||
ELSE
|
ELSE
|
||||||
status_change := 'VERIFIER_FALSE';
|
status_change := 'MODERATOR_FALSE';
|
||||||
END IF;
|
END IF;
|
||||||
INSERT INTO "Notification" ("userId", "type", "aboutAccountStatusChange")
|
INSERT INTO "Notification" ("userId", "type", "aboutAccountStatusChange")
|
||||||
VALUES (NEW.id, 'ACCOUNT_STATUS_CHANGE', status_change);
|
VALUES (NEW.id, 'ACCOUNT_STATUS_CHANGE', status_change);
|
||||||
@@ -57,6 +57,6 @@ DROP TRIGGER IF EXISTS user_status_change_notifications_trigger ON "User";
|
|||||||
|
|
||||||
-- Create the trigger to fire after updates on specific status columns
|
-- Create the trigger to fire after updates on specific status columns
|
||||||
CREATE TRIGGER user_status_change_notifications_trigger
|
CREATE TRIGGER user_status_change_notifications_trigger
|
||||||
AFTER UPDATE OF admin, verified, verifier, spammer ON "User"
|
AFTER UPDATE OF admin, verified, moderator, spammer ON "User"
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION trigger_user_status_change_notifications();
|
EXECUTE FUNCTION trigger_user_status_change_notifications();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ async function createAccount(preGeneratedToken?: string) {
|
|||||||
verifiedLink,
|
verifiedLink,
|
||||||
verified: !!verifiedLink,
|
verified: !!verifiedLink,
|
||||||
admin: faker.datatype.boolean({ probability: 0.1 }),
|
admin: faker.datatype.boolean({ probability: 0.1 }),
|
||||||
verifier: faker.datatype.boolean({ probability: 0.1 }),
|
moderator: faker.datatype.boolean({ probability: 0.1 }),
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
serviceAffiliations: true,
|
serviceAffiliations: true,
|
||||||
@@ -899,19 +899,19 @@ const specialUsersData = {
|
|||||||
envToken: 'DEV_ADMIN_USER_SECRET_TOKEN',
|
envToken: 'DEV_ADMIN_USER_SECRET_TOKEN',
|
||||||
defaultToken: 'admin',
|
defaultToken: 'admin',
|
||||||
admin: true,
|
admin: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
verifiedLink: 'https://kycnot.me',
|
verifiedLink: 'https://kycnot.me',
|
||||||
totalKarma: 1001,
|
totalKarma: 1001,
|
||||||
link: 'https://kycnot.me',
|
link: 'https://kycnot.me',
|
||||||
picture: 'https://comments.kycnot.me/api/users/549f290e-0542-4c18-b437-5b64b35758f0/avatar?size=L',
|
picture: 'https://comments.kycnot.me/api/users/549f290e-0542-4c18-b437-5b64b35758f0/avatar?size=L',
|
||||||
},
|
},
|
||||||
verifier: {
|
moderator: {
|
||||||
name: 'verifier_dev',
|
name: 'moderator_dev',
|
||||||
envToken: 'DEV_VERIFIER_USER_SECRET_TOKEN',
|
envToken: 'DEV_MODERATOR_USER_SECRET_TOKEN',
|
||||||
defaultToken: 'verifier',
|
defaultToken: 'moderator',
|
||||||
admin: false,
|
admin: false,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
verifiedLink: 'https://kycnot.me',
|
verifiedLink: 'https://kycnot.me',
|
||||||
totalKarma: 1001,
|
totalKarma: 1001,
|
||||||
@@ -923,7 +923,7 @@ const specialUsersData = {
|
|||||||
envToken: 'DEV_VERIFIED_USER_SECRET_TOKEN',
|
envToken: 'DEV_VERIFIED_USER_SECRET_TOKEN',
|
||||||
defaultToken: 'verified',
|
defaultToken: 'verified',
|
||||||
admin: false,
|
admin: false,
|
||||||
verifier: false,
|
moderator: false,
|
||||||
verified: true,
|
verified: true,
|
||||||
verifiedLink: 'https://kycnot.me',
|
verifiedLink: 'https://kycnot.me',
|
||||||
totalKarma: 1001,
|
totalKarma: 1001,
|
||||||
@@ -933,7 +933,7 @@ const specialUsersData = {
|
|||||||
envToken: 'DEV_NORMAL_USER_SECRET_TOKEN',
|
envToken: 'DEV_NORMAL_USER_SECRET_TOKEN',
|
||||||
defaultToken: 'normal',
|
defaultToken: 'normal',
|
||||||
admin: false,
|
admin: false,
|
||||||
verifier: false,
|
moderator: false,
|
||||||
verified: false,
|
verified: false,
|
||||||
},
|
},
|
||||||
spam: {
|
spam: {
|
||||||
@@ -941,7 +941,7 @@ const specialUsersData = {
|
|||||||
envToken: 'DEV_SPAM_USER_SECRET_TOKEN',
|
envToken: 'DEV_SPAM_USER_SECRET_TOKEN',
|
||||||
defaultToken: 'spam',
|
defaultToken: 'spam',
|
||||||
admin: false,
|
admin: false,
|
||||||
verifier: false,
|
moderator: false,
|
||||||
verified: false,
|
verified: false,
|
||||||
totalKarma: -100,
|
totalKarma: -100,
|
||||||
spammer: true,
|
spammer: true,
|
||||||
@@ -1306,7 +1306,7 @@ async function runFaker() {
|
|||||||
tx.internalUserNote.create({
|
tx.internalUserNote.create({
|
||||||
data: generateFakeInternalNote(
|
data: generateFakeInternalNote(
|
||||||
user.id,
|
user.id,
|
||||||
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.verifier.id])
|
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.moderator.id])
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -1323,7 +1323,7 @@ async function runFaker() {
|
|||||||
tx.internalUserNote.create({
|
tx.internalUserNote.create({
|
||||||
data: generateFakeInternalNote(
|
data: generateFakeInternalNote(
|
||||||
user.id,
|
user.id,
|
||||||
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.verifier.id])
|
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.moderator.id])
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const selectUserReturnFields = {
|
|||||||
picture: true,
|
picture: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
verifiedLink: true,
|
verifiedLink: true,
|
||||||
secretTokenHash: true,
|
secretTokenHash: true,
|
||||||
totalKarma: true,
|
totalKarma: true,
|
||||||
@@ -55,7 +55,7 @@ export const adminUserActions = {
|
|||||||
.default(null) // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
.default(null) // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
.transform((val) => val || null),
|
.transform((val) => val || null),
|
||||||
pictureFile: z.instanceof(File).optional(),
|
pictureFile: z.instanceof(File).optional(),
|
||||||
type: z.array(z.enum(['admin', 'verifier', 'spammer'])),
|
type: z.array(z.enum(['admin', 'moderator', 'spammer'])),
|
||||||
verifiedLink: z
|
verifiedLink: z
|
||||||
.string()
|
.string()
|
||||||
.url('Invalid URL')
|
.url('Invalid URL')
|
||||||
@@ -101,7 +101,7 @@ export const adminUserActions = {
|
|||||||
verified: !!valuesToUpdate.verifiedLink,
|
verified: !!valuesToUpdate.verifiedLink,
|
||||||
picture: pictureUrl,
|
picture: pictureUrl,
|
||||||
admin: type.includes('admin'),
|
admin: type.includes('admin'),
|
||||||
verifier: type.includes('verifier'),
|
moderator: type.includes('moderator'),
|
||||||
spammer: type.includes('spammer'),
|
spammer: type.includes('spammer'),
|
||||||
},
|
},
|
||||||
select: selectUserReturnFields,
|
select: selectUserReturnFields,
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ export const commentActions = {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
moderate: defineProtectedAction({
|
moderate: defineProtectedAction({
|
||||||
permissions: ['admin', 'verifier'],
|
permissions: ['admin', 'moderator'],
|
||||||
input: z.object({
|
input: z.object({
|
||||||
commentId: z.number(),
|
commentId: z.number(),
|
||||||
userId: z.number(),
|
userId: z.number(),
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ const isHighlighted = comment.id === highlightedCommentId
|
|||||||
const userVote = user ? comment.votes.find((v) => v.userId === user.id) : null
|
const userVote = user ? comment.votes.find((v) => v.userId === user.id) : null
|
||||||
|
|
||||||
const isAuthor = user?.id === comment.author.id
|
const isAuthor = user?.id === comment.author.id
|
||||||
const isAdminOrVerifier = !!user && (user.admin || user.verifier)
|
const isAdminOrModerator = !!user && (user.admin || user.moderator)
|
||||||
const isAuthorOrPrivileged = isAuthor || isAdminOrVerifier
|
const isAuthorOrPrivileged = isAuthor || isAdminOrModerator
|
||||||
|
|
||||||
// Check if user is new (less than 1 week old)
|
// Check if user is new (less than 1 week old)
|
||||||
const isNewUser =
|
const isNewUser =
|
||||||
@@ -75,7 +75,7 @@ const isRatingActive =
|
|||||||
!comment.suspicious &&
|
!comment.suspicious &&
|
||||||
(comment.status === 'APPROVED' || comment.status === 'VERIFIED')
|
(comment.status === 'APPROVED' || comment.status === 'VERIFIED')
|
||||||
|
|
||||||
// Skip rendering if comment is not approved/verified and user is not the author or admin/verifier
|
// Skip rendering if comment is not approved/verified and user is not the author or admin/moderator
|
||||||
const shouldShow =
|
const shouldShow =
|
||||||
comment.status === 'APPROVED' ||
|
comment.status === 'APPROVED' ||
|
||||||
comment.status === 'VERIFIED' ||
|
comment.status === 'VERIFIED' ||
|
||||||
@@ -164,10 +164,10 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{
|
{
|
||||||
(comment.author.verified || comment.author.admin || comment.author.verifier) && (
|
(comment.author.verified || comment.author.admin || comment.author.moderator) && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
text={`${
|
text={`${
|
||||||
comment.author.admin || comment.author.verifier
|
comment.author.admin || comment.author.moderator
|
||||||
? `KYCnot.me ${comment.author.admin ? 'Admin' : 'Moderator'}${comment.author.verifiedLink ? '. ' : ''}`
|
? `KYCnot.me ${comment.author.admin ? 'Admin' : 'Moderator'}${comment.author.verifiedLink ? '. ' : ''}`
|
||||||
: ''
|
: ''
|
||||||
}${comment.author.verifiedLink ? `Related to ${comment.author.verifiedLink}` : ''}`}
|
}${comment.author.verifiedLink ? `Related to ${comment.author.verifiedLink}` : ''}`}
|
||||||
@@ -186,7 +186,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
comment.author.verifier && !comment.author.admin && (
|
comment.author.moderator && !comment.author.admin && (
|
||||||
<BadgeSmall
|
<BadgeSmall
|
||||||
icon="ri:graduation-cap-fill"
|
icon="ri:graduation-cap-fill"
|
||||||
color="teal"
|
color="teal"
|
||||||
@@ -198,14 +198,14 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
isNewUser && !comment.author.admin && !comment.author.verifier && (
|
isNewUser && !comment.author.admin && !comment.author.moderator && (
|
||||||
<Tooltip text={`Joined ${formatDateShort(comment.author.createdAt, { hourPrecision: true })}`}>
|
<Tooltip text={`Joined ${formatDateShort(comment.author.createdAt, { hourPrecision: true })}`}>
|
||||||
<BadgeSmall icon="ri:user-add-fill" color="purple" text="New User" variant="faded" inlineIcon />
|
<BadgeSmall icon="ri:user-add-fill" color="purple" text="New User" variant="faded" inlineIcon />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
authorUnlocks.highKarmaBadge && !comment.author.admin && !comment.author.verifier && (
|
authorUnlocks.highKarmaBadge && !comment.author.admin && !comment.author.moderator && (
|
||||||
<BadgeSmall
|
<BadgeSmall
|
||||||
icon={karmaUnlocksById.highKarmaBadge.icon}
|
icon={karmaUnlocksById.highKarmaBadge.icon}
|
||||||
color="lime"
|
color="lime"
|
||||||
@@ -380,7 +380,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
user && (user.admin || user.verifier) && comment.internalNote && (
|
user && (user.admin || user.moderator) && comment.internalNote && (
|
||||||
<div class="mt-2 peer-checked/collapse:hidden">
|
<div class="mt-2 peer-checked/collapse:hidden">
|
||||||
<div class="border-l-2 border-red-600 bg-red-900/20 py-0.5 pl-2 text-xs">
|
<div class="border-l-2 border-red-600 bg-red-900/20 py-0.5 pl-2 text-xs">
|
||||||
<span class="font-medium text-red-400">Internal note:</span>
|
<span class="font-medium text-red-400">Internal note:</span>
|
||||||
@@ -391,7 +391,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
user && (user.admin || user.verifier) && comment.privateContext && (
|
user && (user.admin || user.moderator) && comment.privateContext && (
|
||||||
<div class="mt-2 peer-checked/collapse:hidden">
|
<div class="mt-2 peer-checked/collapse:hidden">
|
||||||
<div class="border-l-2 border-blue-600 bg-blue-900/20 py-0.5 pl-2 text-xs">
|
<div class="border-l-2 border-blue-600 bg-blue-900/20 py-0.5 pl-2 text-xs">
|
||||||
<span class="font-medium text-blue-400">Private context:</span>
|
<span class="font-medium text-blue-400">Private context:</span>
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ const { comment, class: className, ...divProps } = Astro.props
|
|||||||
|
|
||||||
const user = Astro.locals.user
|
const user = Astro.locals.user
|
||||||
|
|
||||||
// Only render for admin/verifier users
|
// Only render for admin/moderator users
|
||||||
if (!user || !user.admin || !user.verifier) return null
|
if (!user || !user.admin || !user.moderator) return null
|
||||||
---
|
---
|
||||||
|
|
||||||
<div {...divProps} class={cn('text-xs', className)}>
|
<div {...divProps} class={cn('text-xs', className)}>
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ function makeReplySchema(comment: CommentWithRepliesPopulated): Comment {
|
|||||||
Most Upvotes
|
Most Upvotes
|
||||||
</a>
|
</a>
|
||||||
{
|
{
|
||||||
user && (user.admin || user.verifier) && (
|
user && (user.admin || user.moderator) && (
|
||||||
<a
|
<a
|
||||||
href={getSortUrl('status')}
|
href={getSortUrl('status')}
|
||||||
class={cn([
|
class={cn([
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ export const {
|
|||||||
notificationTitle: 'Your account is no longer verified',
|
notificationTitle: 'Your account is no longer verified',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'VERIFIER_TRUE',
|
value: 'MODERATOR_TRUE',
|
||||||
label: 'Verifier role granted',
|
label: 'Moderator role granted',
|
||||||
notificationTitle: 'Verifier role granted',
|
notificationTitle: 'Moderator role granted',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'VERIFIER_FALSE',
|
value: 'MODERATOR_FALSE',
|
||||||
label: 'Verifier role revoked',
|
label: 'Moderator role revoked',
|
||||||
notificationTitle: 'Verifier role revoked',
|
notificationTitle: 'Moderator role revoked',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'SPAMMER_TRUE',
|
value: 'SPAMMER_TRUE',
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const commentReplyQuery = {
|
|||||||
name: true,
|
name: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
displayName: true,
|
displayName: true,
|
||||||
picture: true,
|
picture: true,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
import type { MaybePromise } from 'astro/actions/runtime/utils.js'
|
import type { MaybePromise } from 'astro/actions/runtime/utils.js'
|
||||||
import type { z } from 'astro/zod'
|
import type { z } from 'astro/zod'
|
||||||
|
|
||||||
type SpecialUserPermission = 'admin' | 'verified' | 'verifier'
|
type SpecialUserPermission = 'admin' | 'verified' | 'moderator'
|
||||||
type Permission = SpecialUserPermission | 'guest' | 'not-spammer' | 'user'
|
type Permission = SpecialUserPermission | 'guest' | 'not-spammer' | 'user'
|
||||||
|
|
||||||
type ActionAPIContextWithUser = ActionAPIContext & {
|
type ActionAPIContextWithUser = ActionAPIContext & {
|
||||||
@@ -87,8 +87,8 @@ export function defineProtectedAction<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(permissions === 'verifier' || (Array.isArray(permissions) && permissions.includes('verifier'))) &&
|
(permissions === 'moderator' || (Array.isArray(permissions) && permissions.includes('moderator'))) &&
|
||||||
!context.locals.user.verifier
|
!context.locals.user.moderator
|
||||||
) {
|
) {
|
||||||
if (context.locals.user.spammer) {
|
if (context.locals.user.spammer) {
|
||||||
throw new ActionError({
|
throw new ActionError({
|
||||||
@@ -98,7 +98,7 @@ export function defineProtectedAction<
|
|||||||
}
|
}
|
||||||
throw new ActionError({
|
throw new ActionError({
|
||||||
code: 'FORBIDDEN',
|
code: 'FORBIDDEN',
|
||||||
message: 'Verifier privileges required.',
|
message: 'Moderator privileges required.',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ const USER_SECRET_TOKEN_DEV_USERS_REGEX = (() => {
|
|||||||
defaultToken: 'admin',
|
defaultToken: 'admin',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
envToken: 'DEV_VERIFIER_USER_SECRET_TOKEN',
|
envToken: 'DEV_MODERATOR_USER_SECRET_TOKEN',
|
||||||
defaultToken: 'verifier',
|
defaultToken: 'moderator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
envToken: 'DEV_VERIFIED_USER_SECRET_TOKEN',
|
envToken: 'DEV_VERIFIED_USER_SECRET_TOKEN',
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const user = await Astro.locals.banners.try('user', async () => {
|
|||||||
spammer: true,
|
spammer: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
verifiedLink: true,
|
verifiedLink: true,
|
||||||
totalKarma: true,
|
totalKarma: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
@@ -206,7 +206,7 @@ if (!user) return Astro.rewrite('/404')
|
|||||||
</h1>
|
</h1>
|
||||||
{user.displayName && <p class="text-day-200 font-title">{user.name}</p>}
|
{user.displayName && <p class="text-day-200 font-title">{user.name}</p>}
|
||||||
{
|
{
|
||||||
(user.admin || user.verified || user.verifier) && (
|
(user.admin || user.verified || user.moderator) && (
|
||||||
<div class="mt-1 flex gap-2">
|
<div class="mt-1 flex gap-2">
|
||||||
{user.admin && (
|
{user.admin && (
|
||||||
<span class="rounded-full border border-red-500/50 bg-red-500/20 px-2 py-0.5 text-xs text-red-400">
|
<span class="rounded-full border border-red-500/50 bg-red-500/20 px-2 py-0.5 text-xs text-red-400">
|
||||||
@@ -218,9 +218,9 @@ if (!user) return Astro.rewrite('/404')
|
|||||||
verified
|
verified
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{user.verifier && (
|
{user.moderator && (
|
||||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||||
verifier
|
moderator
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -356,14 +356,14 @@ if (!user) return Astro.rewrite('/404')
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
user.verifier && (
|
user.moderator && (
|
||||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||||
Verifier
|
Moderator
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!user.admin && !user.verified && !user.verifier && (
|
!user.admin && !user.verified && !user.moderator && (
|
||||||
<span class="border-day-700/50 bg-day-700/20 text-day-400 rounded-full border px-2 py-0.5 text-xs">
|
<span class="border-day-700/50 bg-day-700/20 text-day-400 rounded-full border px-2 py-0.5 text-xs">
|
||||||
Standard User
|
Standard User
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { prisma } from '../../lib/prisma'
|
|||||||
import { urlWithParams } from '../../lib/urls'
|
import { urlWithParams } from '../../lib/urls'
|
||||||
|
|
||||||
const user = Astro.locals.user
|
const user = Astro.locals.user
|
||||||
if (!user || (!user.admin && !user.verifier)) {
|
if (!user || (!user.admin && !user.moderator)) {
|
||||||
return Astro.rewrite('/404')
|
return Astro.rewrite('/404')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ type AdminLink = {
|
|||||||
icon: ComponentProps<typeof Icon>['name']
|
icon: ComponentProps<typeof Icon>['name']
|
||||||
title: string
|
title: string
|
||||||
href: string
|
href: string
|
||||||
description: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const adminLinks: AdminLink[] = [
|
const adminLinks: AdminLink[] = [
|
||||||
@@ -17,37 +16,36 @@ const adminLinks: AdminLink[] = [
|
|||||||
icon: 'ri:box-3-line',
|
icon: 'ri:box-3-line',
|
||||||
title: 'Services',
|
title: 'Services',
|
||||||
href: '/admin/services',
|
href: '/admin/services',
|
||||||
description: 'Manage your available services',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'ri:file-list-3-line',
|
icon: 'ri:file-list-3-line',
|
||||||
title: 'Attributes',
|
title: 'Attributes',
|
||||||
href: '/admin/attributes',
|
href: '/admin/attributes',
|
||||||
description: 'Configure service attributes',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'ri:user-3-line',
|
icon: 'ri:user-3-line',
|
||||||
title: 'Users',
|
title: 'Users',
|
||||||
href: '/admin/users',
|
href: '/admin/users',
|
||||||
description: 'Manage user accounts',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'ri:chat-settings-line',
|
icon: 'ri:chat-settings-line',
|
||||||
title: 'Comments',
|
title: 'Comments',
|
||||||
href: '/admin/comments',
|
href: '/admin/comments',
|
||||||
description: 'Moderate user comments',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'ri:lightbulb-line',
|
icon: 'ri:lightbulb-line',
|
||||||
title: 'Service suggestions',
|
title: 'Service suggestions',
|
||||||
href: '/admin/service-suggestions',
|
href: '/admin/service-suggestions',
|
||||||
description: 'Review and manage service suggestions',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'ri:megaphone-line',
|
icon: 'ri:megaphone-line',
|
||||||
title: 'Announcements',
|
title: 'Announcements',
|
||||||
href: '/admin/announcements',
|
href: '/admin/announcements',
|
||||||
description: 'Manage site announcements',
|
},
|
||||||
|
{
|
||||||
|
icon: 'ri:database-2-line',
|
||||||
|
title: 'Database',
|
||||||
|
href: 'https://db.kycnot.me',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
---
|
---
|
||||||
@@ -58,23 +56,17 @@ const adminLinks: AdminLink[] = [
|
|||||||
Admin Dashboard
|
Admin Dashboard
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
<div class="grid grid-cols-[repeat(auto-fill,minmax(calc(var(--spacing)*40),1fr))] gap-4">
|
||||||
{
|
{
|
||||||
adminLinks.map((link) => (
|
adminLinks.map((link) => (
|
||||||
<a
|
<a
|
||||||
href={link.href}
|
href={link.href}
|
||||||
class="group block rounded-lg border border-zinc-800 bg-gradient-to-br from-zinc-900/90 to-zinc-900/50 p-6 shadow-lg backdrop-blur-xs transition-all duration-300 hover:-translate-y-0.5 hover:from-zinc-800/90 hover:to-zinc-800/50 hover:shadow-xl hover:shadow-zinc-900/20"
|
class="group flex flex-col items-center justify-evenly rounded-lg border border-zinc-800 bg-gradient-to-br from-zinc-900/90 to-zinc-900/50 py-3 text-center shadow-lg backdrop-blur-xs transition-all duration-300 hover:-translate-y-0.5 hover:from-zinc-800/90 hover:to-zinc-800/50 hover:shadow-xl hover:shadow-zinc-900/20"
|
||||||
>
|
>
|
||||||
<div class="mb-4 flex items-center gap-3">
|
<Icon name={link.icon} class="size-8 text-zinc-400 transition-colors group-hover:text-green-400" />
|
||||||
<Icon
|
<span class="font-title text-xl leading-none font-semibold text-zinc-100 transition-colors group-hover:text-green-400">
|
||||||
name={link.icon}
|
{link.title}
|
||||||
class="h-6 w-6 text-zinc-400 transition-colors group-hover:text-green-400"
|
</span>
|
||||||
/>
|
|
||||||
<h2 class="font-title text-xl font-semibold text-zinc-100 transition-colors group-hover:text-green-400">
|
|
||||||
{link.title}
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
<p class="text-sm text-zinc-400">{link.description}</p>
|
|
||||||
</a>
|
</a>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const [user, allServices] = await Astro.locals.banners.tryMany([
|
|||||||
link: true,
|
link: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
spammer: true,
|
spammer: true,
|
||||||
verifiedLink: true,
|
verifiedLink: true,
|
||||||
internalNotes: {
|
internalNotes: {
|
||||||
@@ -141,7 +141,7 @@ if (!user) return Astro.rewrite('/404')
|
|||||||
<div class="mb-4 flex flex-wrap justify-center gap-2">
|
<div class="mb-4 flex flex-wrap justify-center gap-2">
|
||||||
{user.admin && <BadgeSmall color="green" text="Admin" icon="ri:shield-star-fill" />}
|
{user.admin && <BadgeSmall color="green" text="Admin" icon="ri:shield-star-fill" />}
|
||||||
{user.verified && <BadgeSmall color="cyan" text="Verified" icon="ri:verified-badge-fill" />}
|
{user.verified && <BadgeSmall color="cyan" text="Verified" icon="ri:verified-badge-fill" />}
|
||||||
{user.verifier && <BadgeSmall color="blue" text="Moderator" icon="ri:graduation-cap-fill" />}
|
{user.moderator && <BadgeSmall color="blue" text="Moderator" icon="ri:graduation-cap-fill" />}
|
||||||
{user.spammer && <BadgeSmall color="red" text="Spammer" icon="ri:alert-fill" />}
|
{user.spammer && <BadgeSmall color="red" text="Spammer" icon="ri:alert-fill" />}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ if (!user) return Astro.rewrite('/404')
|
|||||||
label="Type"
|
label="Type"
|
||||||
options={[
|
options={[
|
||||||
{ label: 'Admin', value: 'admin', icon: 'ri:shield-star-fill' },
|
{ label: 'Admin', value: 'admin', icon: 'ri:shield-star-fill' },
|
||||||
{ label: 'Moderator', value: 'verifier', icon: 'ri:graduation-cap-fill' },
|
{ label: 'Moderator', value: 'moderator', icon: 'ri:graduation-cap-fill' },
|
||||||
{ label: 'Spammer', value: 'spammer', icon: 'ri:alert-fill' },
|
{ label: 'Spammer', value: 'spammer', icon: 'ri:alert-fill' },
|
||||||
{
|
{
|
||||||
label: 'Verified',
|
label: 'Verified',
|
||||||
@@ -239,7 +239,7 @@ if (!user) return Astro.rewrite('/404')
|
|||||||
selectedValue={[
|
selectedValue={[
|
||||||
user.admin ? 'admin' : null,
|
user.admin ? 'admin' : null,
|
||||||
user.verified ? 'verified' : null,
|
user.verified ? 'verified' : null,
|
||||||
user.verifier ? 'verifier' : null,
|
user.moderator ? 'moderator' : null,
|
||||||
user.spammer ? 'spammer' : null,
|
user.spammer ? 'spammer' : null,
|
||||||
].filter((v) => v !== null)}
|
].filter((v) => v !== null)}
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const { data: filters } = zodParseQueryParamsStoringErrors(
|
|||||||
'sort-by': z.enum(['name', 'role', 'createdAt', 'karma']).default('createdAt'),
|
'sort-by': z.enum(['name', 'role', 'createdAt', 'karma']).default('createdAt'),
|
||||||
'sort-order': z.enum(['asc', 'desc']).default('desc'),
|
'sort-order': z.enum(['asc', 'desc']).default('desc'),
|
||||||
search: z.string().optional(),
|
search: z.string().optional(),
|
||||||
role: z.enum(['user', 'admin', 'verifier', 'verified', 'spammer']).optional(),
|
role: z.enum(['user', 'admin', 'moderator', 'verified', 'spammer']).optional(),
|
||||||
},
|
},
|
||||||
Astro
|
Astro
|
||||||
)
|
)
|
||||||
@@ -46,7 +46,7 @@ if (filters.role) {
|
|||||||
switch (filters.role) {
|
switch (filters.role) {
|
||||||
case 'user': {
|
case 'user': {
|
||||||
whereClause.admin = false
|
whereClause.admin = false
|
||||||
whereClause.verifier = false
|
whereClause.moderator = false
|
||||||
whereClause.verified = false
|
whereClause.verified = false
|
||||||
whereClause.spammer = false
|
whereClause.spammer = false
|
||||||
break
|
break
|
||||||
@@ -55,8 +55,8 @@ if (filters.role) {
|
|||||||
whereClause.admin = true
|
whereClause.admin = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'verifier': {
|
case 'moderator': {
|
||||||
whereClause.verifier = true
|
whereClause.moderator = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'verified': {
|
case 'verified': {
|
||||||
@@ -80,7 +80,7 @@ const dbUsers = await prisma.user.findMany({
|
|||||||
picture: true,
|
picture: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
spammer: true,
|
spammer: true,
|
||||||
totalKarma: true,
|
totalKarma: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
@@ -147,7 +147,7 @@ const makeSortUrl = (sortBy: NonNullable<(typeof filters)['sort-by']>) => {
|
|||||||
<option value="" selected={!filters.role}>All Users</option>
|
<option value="" selected={!filters.role}>All Users</option>
|
||||||
<option value="user" selected={filters.role === 'user'}>Regular Users</option>
|
<option value="user" selected={filters.role === 'user'}>Regular Users</option>
|
||||||
<option value="admin" selected={filters.role === 'admin'}>Admins</option>
|
<option value="admin" selected={filters.role === 'admin'}>Admins</option>
|
||||||
<option value="verifier" selected={filters.role === 'verifier'}>Verifiers</option>
|
<option value="moderator" selected={filters.role === 'moderator'}>Moderators</option>
|
||||||
<option value="verified" selected={filters.role === 'verified'}>Verified Users</option>
|
<option value="verified" selected={filters.role === 'verified'}>Verified Users</option>
|
||||||
<option value="spammer" selected={filters.role === 'spammer'}>Spammers</option>
|
<option value="spammer" selected={filters.role === 'spammer'}>Spammers</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -277,10 +277,10 @@ const makeSortUrl = (sortBy: NonNullable<(typeof filters)['sort-by']>) => {
|
|||||||
Verified
|
Verified
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{user.verifier && (
|
{user.moderator && (
|
||||||
<span class="inline-flex items-center gap-1 rounded-md bg-blue-900/30 px-2 py-0.5 text-xs font-medium text-blue-400">
|
<span class="inline-flex items-center gap-1 rounded-md bg-blue-900/30 px-2 py-0.5 text-xs font-medium text-blue-400">
|
||||||
<Icon name="ri:shield-check-fill" class="size-3.5" />
|
<Icon name="ri:shield-check-fill" class="size-3.5" />
|
||||||
Verifier
|
Moderator
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const user = await Astro.locals.banners.try('user', async () => {
|
|||||||
spammer: true,
|
spammer: true,
|
||||||
verified: true,
|
verified: true,
|
||||||
admin: true,
|
admin: true,
|
||||||
verifier: true,
|
moderator: true,
|
||||||
verifiedLink: true,
|
verifiedLink: true,
|
||||||
totalKarma: true,
|
totalKarma: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
@@ -208,7 +208,7 @@ const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id
|
|||||||
sameAs: user.link ? [user.link] : undefined,
|
sameAs: user.link ? [user.link] : undefined,
|
||||||
description: `User profile page for ${user.displayName ?? user.name} on KYCnot.me`,
|
description: `User profile page for ${user.displayName ?? user.name} on KYCnot.me`,
|
||||||
identifier: [user.name, user.id.toString()],
|
identifier: [user.name, user.id.toString()],
|
||||||
jobTitle: user.admin ? 'Administrator' : user.verifier ? 'Moderator' : undefined,
|
jobTitle: user.admin ? 'Administrator' : user.moderator ? 'Moderator' : undefined,
|
||||||
memberOf: KYCNOTME_SCHEMA_MINI,
|
memberOf: KYCNOTME_SCHEMA_MINI,
|
||||||
interactionStatistic: [
|
interactionStatistic: [
|
||||||
{
|
{
|
||||||
@@ -281,9 +281,9 @@ const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
user.verifier && (
|
user.moderator && (
|
||||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||||
verifier
|
moderator
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -415,14 +415,14 @@ const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
user.verifier && (
|
user.moderator && (
|
||||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||||
Verifier
|
Moderator
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!user.admin && !user.verified && !user.verifier && (
|
!user.admin && !user.verified && !user.moderator && (
|
||||||
<span class="border-day-700/50 bg-day-700/20 text-day-400 rounded-full border px-2 py-0.5 text-xs">
|
<span class="border-day-700/50 bg-day-700/20 text-day-400 rounded-full border px-2 py-0.5 text-xs">
|
||||||
Standard User
|
Standard User
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user