Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/pages/edits/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const EditComponent: FC = () => {
const buttons = (isAdmin(auth.user) || auth.user?.id === edit.user?.id) &&
edit.status === VoteStatusEnum.PENDING && (
<div className="d-flex justify-content-end">
{auth.user?.id === edit.user?.id &&
{(auth.user?.id === edit.user?.id || isAdmin(auth.user)) &&
edit.operation !== OperationEnum.DESTROY &&
!edit.updated && (
<Link to={createHref(ROUTE_EDIT_UPDATE, edit)} className="me-2">
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/edits/EditUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SceneEditUpdate } from "src/pages/scenes/SceneEditUpdate";
import { PerformerEditUpdate } from "src/pages/performers/PerformerEditUpdate";
import { TagEditUpdate } from "src/pages/tags/TagEditUpdate";
import { StudioEditUpdate } from "src/pages/studios/StudioEditUpdate";
import { isAdmin } from "src/utils";

const EditUpdateComponent: FC = () => {
const auth = useContext(AuthContext);
Expand All @@ -18,7 +19,7 @@ const EditUpdateComponent: FC = () => {

const edit = data?.findEdit;
if (!edit) return <ErrorMessage error="Failed to load edit." />;
if (edit.user?.id != auth.user?.id)
if (edit.user?.id != auth.user?.id && !isAdmin(auth.user))
return <ErrorMessage error="Only the creator can update edits." />;
if (edit.updated)
return <ErrorMessage error="Edits can only be updated once." />;
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/resolver_mutation_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (r *mutationResolver) SceneEditUpdate(ctx context.Context, id uuid.UUID, in
return nil, err
}

if existingEdit.UserID.UUID != currentUser.ID {
if validateUserOrAdmin(ctx, existingEdit.UserID.UUID) != nil {
return nil, ErrUnauthorizedUpdate
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func (r *mutationResolver) StudioEditUpdate(ctx context.Context, id uuid.UUID, i
return nil, err
}

if existingEdit.UserID.UUID != currentUser.ID {
if validateUserOrAdmin(ctx, existingEdit.UserID.UUID) != nil {
return nil, ErrUnauthorizedUpdate
}

Expand Down Expand Up @@ -228,7 +228,7 @@ func (r *mutationResolver) TagEditUpdate(ctx context.Context, id uuid.UUID, inpu
return nil, err
}

if existingEdit.UserID.UUID != currentUser.ID {
if validateUserOrAdmin(ctx, existingEdit.UserID.UUID) != nil {
return nil, ErrUnauthorizedUpdate
}

Expand Down Expand Up @@ -311,7 +311,7 @@ func (r *mutationResolver) PerformerEditUpdate(ctx context.Context, id uuid.UUID
return nil, err
}

if existingEdit.UserID.UUID != currentUser.ID {
if validateUserOrAdmin(ctx, existingEdit.UserID.UUID) != nil {
return nil, ErrUnauthorizedUpdate
}

Expand Down