Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessToken.addGrant() should not replace previous grants #109

Closed
shahriar-shojib opened this issue Oct 18, 2023 · 1 comment · Fixed by #112
Closed

AccessToken.addGrant() should not replace previous grants #109

shahriar-shojib opened this issue Oct 18, 2023 · 1 comment · Fixed by #112

Comments

@shahriar-shojib
Copy link
Contributor

Consider this following use case:

const token = new AccessToken();

token.addGrant({
 canPublish: true,
 canSubscribe: true,
 roomJoin: true,
 room: data.meetingID,
 canPublishData: true,
});

if( user.isAdmin ){
 token.addGrant({  roomAdmin: true })
}

This code should keep the previous grants and add roomAdmin grant to the token, instead, it replaces previous grants and adds only roomAdmin grant to the token.

I am not sure if this is intentional, I was not able to join a room with just roomAdmin grant.

I can open a PR that fixes this issue.

https://github.com/livekit/server-sdk-js/blob/e9e24658479c72bbcd156d62f046a51c608d8731/src/AccessToken.ts#L83

@davidzhao
Copy link
Member

@shahriar-shojib I agree.. since it's called addGrant, it should not clear out existing values. If you can open a PR, that'd be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants