-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from r00tat/bugfix/auth
Fehlerbehebung Berechtigungen für subitems eines Einsatzes
- Loading branch information
Showing
15 changed files
with
215 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { UserRecordExtended } from '../../common/users'; | ||
import { | ||
GROUP_COLLECTION_ID, | ||
USER_COLLECTION_ID, | ||
} from '../../components/firebase/firestore'; | ||
import { firestore } from '../../server/firebase/admin'; | ||
|
||
export interface Group { | ||
id?: string; | ||
name: string; | ||
description?: string; | ||
} | ||
|
||
export async function getGroups(): Promise<Group[]> { | ||
const groupDocs = ( | ||
await firestore.collection(GROUP_COLLECTION_ID).orderBy('name', 'asc').get() | ||
).docs; | ||
return groupDocs.map( | ||
(g) => ({ ...g.data(), name: g.data().name || '', id: g.id } as Group) | ||
); | ||
} | ||
|
||
export async function getMyGroups(userId: string): Promise<Group[]> { | ||
const allGropus = await getGroups(); | ||
const myGroupIds = | ||
( | ||
( | ||
await firestore.collection(USER_COLLECTION_ID).doc(userId).get() | ||
).data() as UserRecordExtended | ||
).groups || []; | ||
return allGropus | ||
.filter((g) => g.id && myGroupIds.includes(g.id)) | ||
.sort((a, b) => a.name.localeCompare(b.name)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.