File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed
runtime/server/routes/auth Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ export default defineNuxtConfig({
6363 owner: ' your-username' , // your GitHub username or organization
6464 repo: ' your-repo' , // your repository name
6565 branch: ' main' , // the branch to commit to
66- rootDir: ' ' // optional: if your Nuxt app is in a subdirectory
66+ rootDir: ' ' , // optional: if your Nuxt app is in a subdirectory
67+ private: true // optional: whether the repository is private or public (default: true)
6768 }
6869 }
6970})
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export default defineNuxtConfig({
1919 repo : 'studio' ,
2020 branch : 'main' ,
2121 rootDir : 'playground/docus' ,
22+ private : false
2223 } ,
2324 } ,
2425} )
Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ interface ModuleOptions {
6262 * @default ''
6363 */
6464 rootDir ?: string
65+ /**
66+ * Whether the repository is private or public.
67+ * If set to false, the 'public_repo' scope will be used instead of the 'repo' scope.
68+ * @default true
69+ */
70+ private ?: boolean
6571 }
6672 /**
6773 * Enable Nuxt Studio to edit content and media files on your filesystem.
@@ -89,6 +95,7 @@ export default defineNuxtModule<ModuleOptions>({
8995 repo : '' ,
9096 branch : 'main' ,
9197 rootDir : '' ,
98+ private : true ,
9299 } ,
93100 auth : {
94101 github : {
@@ -140,6 +147,8 @@ export default defineNuxtModule<ModuleOptions>({
140147 // @ts -expect-error todo fix github type issue
141148 github : options . auth ?. github ,
142149 } ,
150+ // @ts -expect-error Autogenerated type does not match with options
151+ repository : options . repository ,
143152 }
144153
145154 addPlugin ( process . env . STUDIO_DEV_SERVER
Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ interface RequestAccessTokenOptions {
8080}
8181
8282export default eventHandler ( async ( event : H3Event ) => {
83- const config = defu ( useRuntimeConfig ( event ) . studio ?. auth ?. github , {
83+ const studioConfig = useRuntimeConfig ( event ) . studio
84+ const config = defu ( studioConfig ?. auth ?. github , {
8485 clientId : process . env . STUDIO_GITHUB_CLIENT_ID ,
8586 clientSecret : process . env . STUDIO_GITHUB_CLIENT_SECRET ,
8687 authorizationURL : 'https://github.com/login/oauth/authorize' ,
@@ -117,8 +118,8 @@ export default eventHandler(async (event: H3Event) => {
117118 if ( config . emailRequired && ! config . scope . includes ( 'user:email' ) ) {
118119 config . scope . push ( 'user:email' )
119120 }
120- if ( config . emailRequired && ! config . scope . includes ( 'repo' ) ) {
121- config . scope . push ( 'repo' )
121+ if ( config . emailRequired && ! config . scope . includes ( 'repo' ) && ! config . scope . includes ( 'public_repo' ) ) {
122+ config . scope . push ( studioConfig . repository . private ? 'repo' : 'public_repo ')
122123 }
123124
124125 return sendRedirect (
You can’t perform that action at this time.
0 commit comments