@@ -31,11 +31,12 @@ async function ensurePodAccess({ id, userId }) {
3131 throw new Error ( "Pod not exists." ) ;
3232 }
3333 if ( pod . repo . owner . id !== userId ) {
34- throw new Error ( "You do not have write access." ) ;
34+ throw new Error ( "You do not have access to this pod ." ) ;
3535 }
3636}
3737
3838export async function repos ( ) {
39+ throw new Error ( "Deprecated" ) ;
3940 const repos = await prisma . repo . findMany ( {
4041 include : {
4142 owner : true ,
@@ -56,10 +57,12 @@ export async function myRepos(_, __, { userId }) {
5657 return repos ;
5758}
5859
59- export async function repo ( _ , { id } ) {
60+ export async function repo ( _ , { id } , { userId } ) {
61+ if ( ! userId ) throw Error ( "Unauthenticated" ) ;
6062 const repo = await prisma . repo . findFirst ( {
6163 where : {
6264 id,
65+ owner : { id : userId } ,
6366 } ,
6467 include : {
6568 owner : true ,
@@ -79,6 +82,7 @@ export async function repo(_, { id }) {
7982}
8083
8184export async function pod ( _ , { id } ) {
85+ throw new Error ( "Deprecated" ) ;
8286 return await prisma . pod . findFirst ( {
8387 where : {
8488 id : id ,
@@ -144,16 +148,10 @@ export async function addPod(_, { repoId, parent, index, input }, { userId }) {
144148 const repo = await prisma . repo . findFirst ( {
145149 where : {
146150 id : repoId ,
147- } ,
148- include : {
149- owner : true ,
151+ owner : { id : userId } ,
150152 } ,
151153 } ) ;
152154 if ( ! repo ) throw new Error ( "Repo not found" ) ;
153- // check ownership
154- if ( repo . owner . id != userId ) {
155- throw new Error ( "You do not have access to the repo." ) ;
156- }
157155 // update all other records
158156 await prisma . pod . updateMany ( {
159157 where : {
0 commit comments