File tree Expand file tree Collapse file tree 3 files changed +24
-16
lines changed Expand file tree Collapse file tree 3 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -33,15 +33,19 @@ export const ExportModal = ({ onClose, initialValues }) => {
33
33
AxiosResponse < string > ,
34
34
AxiosError ,
35
35
{ scopes : Scope [ 'id' ] [ ] }
36
- > ( ( { scopes } ) => axios . post ( '/api/csv/issue' , { scopes } ) , {
37
- onSuccess : ( response ) => {
38
- const file = new File ( [ response . data ] , 'issues.csv' , {
39
- type : 'text/csv;charset=utf-8' ,
40
- } ) ;
41
- saveAs ( file ) ;
42
- onClose ( ) ;
43
- } ,
44
- } ) ;
36
+ > (
37
+ ( { scopes } ) =>
38
+ axios . post ( '/api/csv/issue' , { scopes, provider : 'gitlab' } ) ,
39
+ {
40
+ onSuccess : ( response ) => {
41
+ const file = new File ( [ response . data ] , 'issues.csv' , {
42
+ type : 'text/csv;charset=utf-8' ,
43
+ } ) ;
44
+ saveAs ( file ) ;
45
+ onClose ( ) ;
46
+ } ,
47
+ }
48
+ ) ;
45
49
46
50
const { mutate : exportToGithub , isLoading : isExportToGithubLoading } =
47
51
trpc . issue . export . github . useMutation ( {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Scope } from '@prisma/client';
3
3
4
4
import { useFieldSelectScopeStyles } from '@/app/scopes/useFieldSelectScopeStyles' ;
5
5
import { FieldInput , FieldMultiSelect } from '@/components' ;
6
- import { FieldMarkdown } from '@/components/FieldMarkdown ' ;
6
+ import { FieldMarkdown } from '@/components/FieldMarkDown ' ;
7
7
import { trpc } from '@/utils/trpc' ;
8
8
9
9
export type IssueFormProps = {
Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ export const badRequest = (res: NextApiResponse) => {
18
18
return res . status ( 400 ) . end ( ) ;
19
19
} ;
20
20
21
- export const notSignedIn = ( res : NextApiResponse , url ?: string ) => {
22
- if ( url && ( url as string ) . endsWith ( 'api/csv/issue' ) ) {
23
- return res . status ( 401 ) . json ( { provider : 'gitlab' } ) ;
21
+ export const notSignedIn = ( res : NextApiResponse , req : NextApiRequest ) => {
22
+ const provider = req . body . provider ;
23
+ if ( provider !== undefined ) {
24
+ return res . status ( 401 ) . json ( { provider : provider } ) ;
24
25
}
25
26
26
27
return res . status ( 401 ) . end ( ) ;
@@ -54,10 +55,13 @@ export const apiMethods =
54
55
if ( ! method . isPublic ) {
55
56
// getSession is now deprecated and is way slower than getServerSession because
56
57
// it does an extra fetch out over the internet to confirm data from itself
57
-
58
58
const session = await getServerSession ( req , res , authOptions ) ;
59
- if ( ! session ) {
60
- return notSignedIn ( res , req . url ) ;
59
+ const provider = req . body . provider ;
60
+ if (
61
+ ! session ||
62
+ session . user . accounts . find ( ( x ) => x . provider === provider ) === undefined // If the user doesn't have an account logged in with the given provider.
63
+ ) {
64
+ return notSignedIn ( res , req ) ;
61
65
}
62
66
}
63
67
You can’t perform that action at this time.
0 commit comments