Skip to content

Commit

Permalink
fix(auth): fix graphql types for team permissions in auth package
Browse files Browse the repository at this point in the history
  • Loading branch information
bahdcoder committed Sep 30, 2021
1 parent 18f1a18 commit 183180b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@tensei/social-auth": "^0.9.5"
},
"scripts": {
"example:dev": "yarn ts-node-dev --respawn src/index.ts",
"example:dev": "yarn tensei serve --watch",
"build": "tsc"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default tensei()
welcome(),
cms().plugin(),
auth()
.teams()
.verifyEmails()
.configureTokens({
accessTokenExpiresIn: 60,
Expand All @@ -80,7 +81,8 @@ export default tensei()
])
.db({
type: 'sqlite',
dbName: 'db.sqlite'
dbName: 'db.sqlite',
debug: true
})
.start()
.catch(console.error)
4 changes: 3 additions & 1 deletion packages/auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export class Auth implements AuthContract {
setupFn: AuthSetupFn
} = {
prefix: '',
teamPermissions: [],
teamPermissions: [
permission('all').description('Permission to do everything.')
],
autoFillUser: true,
autoFilterForUser: true,
tokenResource: 'Token',
Expand Down
22 changes: 8 additions & 14 deletions packages/auth/src/teams/Teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,17 @@ export class Teams {
}

return gql`
${this.auth.config.teamPermissions.length > 0
? `
enum TeamPermissionString {
${this.auth.config.teamPermissions.map(
permission => `
${permission.config.slug.split(':').join('_').toUpperCase()}
`
enum TeamPermissionString {
${this.auth.config.teamPermissions.map(permission =>
permission.config.slug.split(':').join('_').toUpperCase()
)}
}
type TeamPermission {
slug: String!
description: String
default: Boolean!
}
`
: ``}
type TeamPermission {
slug: String!
description: String
default: Boolean!
}
input InviteTeamMemberInput {
permissions: [TeamPermissionString]
Expand Down
2 changes: 1 addition & 1 deletion packages/create-tensei-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"prettier": "prettier --write './**/*.{js,json,ts,css}'",
"build": "tsc --p tsconfig.json",
"build": "tsc --p tsconfig.json && copyfiles \"templates/**/*\" build",
"dev": "tsc --watch --p tsconfig.json",
"test": "jest --verbose --runInBand --forceExit"
},
Expand Down

0 comments on commit 183180b

Please sign in to comment.