Skip to content

Commit

Permalink
bugfix: allow users to set their own active flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sushimako committed Dec 31, 2019
1 parent 0707e59 commit 40a9d0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ service cloud.firestore {
allow write: if isAdmin();
}
match /users/{uid} {
allow create: if !signedIn();
allow read: if isUser(uid) || isAdmin();
allow update: if isAdmin() || (isUser(uid) && !("admin" in request.resource.data));
allow create, read, update: if isAdmin() || (isUser(uid) && !("admin" in request.resource.data));

match /animations/{animationId} {
allow read, write: if isUser(uid) || isAdmin();
Expand Down
8 changes: 4 additions & 4 deletions src/Actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const syncLibrary = createAction('UPSERT_ANIMATIONS', async (uid, localLi
), Map());

// store all remote animations locally
remoteLib.map(animation => {
remoteLib.map(animation => {
localStorage.setItem(`animation:${animation.id}`, JSON.stringify(animation));
})

Expand All @@ -32,8 +32,8 @@ export const syncLibrary = createAction('UPSERT_ANIMATIONS', async (uid, localLi
export const signedUp = createAction('LOGIN', (uid, localLib) => {
const lib = localLib.filterNot(a => a.text === INITIAL_ANIMATION_TEXT);
//TODO add more signup context. last login referrer etc
DB.collection('users').doc(uid).set({active: true }, {merge: true});
saveAnimationsToRemote(uid, lib);
DB.collection('users').doc(uid).set({active: true})
.then(() => {saveAnimationsToRemote(uid, lib)})
.catch((err) => {console.log("error during signup: ", err)});
return { uid, admin: false };
});
//

0 comments on commit 40a9d0f

Please sign in to comment.