fix(server): token revokation checks for format (bearer xxx)

This commit is contained in:
Dimitrie Stefanescu
2020-12-11 00:02:20 +00:00
parent b70ef7e8d8
commit 3510aa443b
+6 -1
View File
@@ -21,7 +21,12 @@ module.exports = {
return await createPersonalAccessToken( context.userId, args.token.name, args.token.scopes, args.token.lifespan )
},
async apiTokenRevoke( parent, args, context, info ) {
await revokeToken( args.token.split( ' ' )[ 1 ], context.userId ) // let's not revoke other people's tokens
let id = null
if ( args.token.toLowerCase().includes( "bearer" ) )
id = args.token.split( ' ' )[ 1 ]
else
id = args.token
await revokeToken( id, context.userId ) // let's not revoke other people's tokens
return true
}
}