Skip to content

Instantly share code, notes, and snippets.

@hamiltop
Created May 12, 2022 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamiltop/fd11a4b6d9b556127e9c590b84fdf642 to your computer and use it in GitHub Desktop.
Save hamiltop/fd11a4b6d9b556127e9c590b84fdf642 to your computer and use it in GitHub Desktop.
Access to an organization's FTP credentials
Before:
async sftpCredentials(args: any, ctx: Context) {
return ctx.loaders.FeatureCredentials.getSftpCredentials(args.orgUuid, 'auto-messaging');
},
After
async sftpCredentials(args: any, ctx: Context) {
// We need to have an authenticated user who is an admin for the org uuid
// See https://app.asana.com/0/1142193044639890/1201986092349803/f
const authenticatedAdmin = await isCurrentUserAnAdminForOrg(ctx, args.orgUuid);
if (!authenticatedAdmin) {
// this field is required to be a list. For an unauthenticated request, just return an empty list.
return [];
}
return ctx.loaders.FeatureCredentials.getSftpCredentials(args.orgUuid, 'auto-messaging');
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment