digidem / comapeo-core

A local-first library for collaborating on mapping projects
MIT License
8 stars 1 forks source link

fix: only the project creator can change their role #960

Closed EvanHahn closed 1 week ago

EvanHahn commented 1 week ago

(This diff looks large, but it's just one line of source code and a bunch of tests.)

We have some code like this:

if (isAssigningProjectCreatorRole && !this.#isProjectCreator()) {

The intent: only allow the project creator to change their own role.

However, this.#isProjectCreator returned a Promise, which meant that the second part of the condition always evaluated to false, which meant that the whole condition always evaluated to false, which meant that non-creators could change the creator's role.

This fixes that by making #isProjectCreator return a boolean, not Promise<boolean>.

Found this while working on #188.