feature(auth): replace clerk.com with custom auth (#103)
* feature(auth): replace clerk.com with custom auth * minor fixes * remove notification preferences * decrease live events interval fix(api): cookies.. # Conflicts: # .gitignore # apps/api/src/index.ts # apps/dashboard/src/app/providers.tsx # packages/trpc/src/trpc.ts
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
f28802b1c2
commit
d31d9924a5
@@ -44,10 +44,10 @@ export function useColumns(
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'access',
|
||||
accessorKey: 'projectAccess',
|
||||
header: 'Access',
|
||||
cell: ({ row }) => {
|
||||
const access = pathOr<string[]>([], ['meta', 'access'], row.original);
|
||||
const access = row.original.projectAccess;
|
||||
return (
|
||||
<>
|
||||
{access.map((id) => {
|
||||
@@ -102,7 +102,7 @@ function ActionCell({ row }: { row: Row<IServiceInvite> }) {
|
||||
<DropdownMenuItem
|
||||
className="text-destructive"
|
||||
onClick={() => {
|
||||
revoke.mutate({ memberId: row.original.id });
|
||||
revoke.mutate({ inviteId: row.original.id });
|
||||
}}
|
||||
>
|
||||
Revoke invite
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useRef, useState } from 'react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import { ACTIONS } from '@/components/data-table';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import type { IServiceMember, IServiceProject } from '@openpanel/db';
|
||||
|
||||
export function useColumns(projects: IServiceProject[]) {
|
||||
@@ -77,6 +78,8 @@ function AccessCell({
|
||||
row: Row<IServiceMember>;
|
||||
projects: IServiceProject[];
|
||||
}) {
|
||||
const auth = useAuth();
|
||||
const currentUserId = auth.data?.userId;
|
||||
const initial = useRef(row.original.access.map((item) => item.projectId));
|
||||
const [access, setAccess] = useState<string[]>(
|
||||
row.original.access.map((item) => item.projectId),
|
||||
@@ -88,6 +91,16 @@ function AccessCell({
|
||||
},
|
||||
});
|
||||
|
||||
if (auth.isLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (currentUserId === row.original.userId) {
|
||||
return (
|
||||
<div className="text-muted-foreground">Can't change your own access</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ComboboxAdvanced
|
||||
placeholder="Restrict access to projects"
|
||||
|
||||
Reference in New Issue
Block a user