-
Notifications
You must be signed in to change notification settings - Fork 7
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 #72 from joshxfi/dev
release: v1.0.8.1
- Loading branch information
Showing
18 changed files
with
1,353 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,90 @@ | ||
rules_version = '2'; | ||
service cloud.firestore { | ||
match /databases/{database}/documents { | ||
match /{document=**} { | ||
allow read, write: if request.auth != null; | ||
function docExists(collection, docId) { | ||
return exists(/databases/$(database)/documents/$(collection)/$(docId)); | ||
} | ||
|
||
function isAdmin(userId) { | ||
return docExists('admins', userId); | ||
} | ||
|
||
function currentUser() { | ||
return request.auth.uid; | ||
} | ||
|
||
function userTag() { | ||
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userTag; | ||
} | ||
|
||
function allowedFields(condition, fields) { | ||
return condition && request.resource.data.diff(resource.data).affectedKeys().hasOnly(fields); | ||
} | ||
|
||
match /{documents=**} { | ||
allow read, write: if isAdmin(currentUser()); | ||
} | ||
|
||
match /admins/{adminId} { | ||
allow read, write: if isAdmin(currentUser()); | ||
} | ||
|
||
match /users/{userId} { | ||
allow read: if request.auth != null; | ||
allow create: if !docExists('users', userId); | ||
allow update: if allowedFields(userId.matches(currentUser()), ['username']); | ||
} | ||
|
||
match /rooms/{roomId} { | ||
function isCreator() { | ||
return userTag() == resource.data.creator; | ||
} | ||
|
||
function isRoomAdmin() { | ||
return userTag() in resource.data.admin; | ||
} | ||
|
||
function isMember() { | ||
return userTag() in resource.data.members; | ||
} | ||
|
||
function members(isReq) { | ||
return isReq ? request.resource.data.members : resource.data.members; | ||
} | ||
|
||
allow read: if true; | ||
allow create: if !docExists('rooms', roomId); | ||
allow update: if (allowedFields(!(userTag() in members(false)), ['requests']) | ||
&& members(true).hasAll(members(false))) | ||
|| allowedFields(isCreator(), ['name', 'admin', 'members', 'requests']) | ||
|| allowedFields(isRoomAdmin(), ['members', 'requests']) | ||
|| (allowedFields(isMember(), ['members']) | ||
&& !(userTag() in members(true)) | ||
&& members(true).hasAll(members(false).removeAll([userTag()]))); | ||
allow delete: if isCreator(); | ||
|
||
match /tasks/{taskId} { | ||
function currentRoom() { | ||
return get(/databases/$(database)/documents/rooms/$(roomId)).data; | ||
} | ||
|
||
function roomAdmin() { | ||
return userTag() in currentRoom().admin || userTag() == currentRoom().creator; | ||
} | ||
|
||
function roomMember() { | ||
return userTag() in currentRoom().members; | ||
} | ||
|
||
function addedByUser() { | ||
return userTag() == resource.data.addedBy; | ||
} | ||
|
||
allow read, create: if roomMember() || roomAdmin(); | ||
allow update: if addedByUser() || roomAdmin() | ||
|| allowedFields(roomMember(), ['completedBy']); | ||
allow delete: if addedByUser() || roomAdmin(); | ||
} | ||
} | ||
} | ||
} | ||
} |
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,16 @@ | ||
import React from 'react'; | ||
import { NextPageWithLayout } from 'types/page'; | ||
import { Layout, Markdown } from '@/components'; | ||
import { codeOfConduct } from '@/utils/contents'; | ||
|
||
const CodeOfConduct: NextPageWithLayout = () => { | ||
return <Markdown content={codeOfConduct} />; | ||
}; | ||
|
||
CodeOfConduct.getLayout = (page: React.ReactElement) => ( | ||
<Layout allowAll className='py-20'> | ||
{page} | ||
</Layout> | ||
); | ||
|
||
export default CodeOfConduct; |
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,16 @@ | ||
import React from 'react'; | ||
import { NextPageWithLayout } from 'types/page'; | ||
import { Layout, Markdown } from '@/components'; | ||
import { privacyPolicy } from '@/utils/contents'; | ||
|
||
const PrivacyPolicy: NextPageWithLayout = () => { | ||
return <Markdown content={privacyPolicy} />; | ||
}; | ||
|
||
PrivacyPolicy.getLayout = (page: React.ReactElement) => ( | ||
<Layout allowAll className='py-20'> | ||
{page} | ||
</Layout> | ||
); | ||
|
||
export default PrivacyPolicy; |
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,16 @@ | ||
import React from 'react'; | ||
import { theProject } from '@/utils/contents'; | ||
import { Layout, Markdown } from '@/components'; | ||
import { NextPageWithLayout } from 'types/page'; | ||
|
||
const TheProject: NextPageWithLayout = () => { | ||
return <Markdown content={theProject} />; | ||
}; | ||
|
||
TheProject.getLayout = (page: React.ReactElement) => ( | ||
<Layout allowAll className='py-20'> | ||
{page} | ||
</Layout> | ||
); | ||
|
||
export default TheProject; |
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,13 @@ | ||
import React from 'react'; | ||
import remarkGfm from 'remark-gfm'; | ||
import ReactMarkdown from 'react-markdown'; | ||
|
||
const Markdown = ({ content }: { content: string }) => { | ||
return ( | ||
<article className='content prose max-w-none'> | ||
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown> | ||
</article> | ||
); | ||
}; | ||
|
||
export default Markdown; |
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.
2e8939b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
track-as-one – ./
track-as-one-joshxfi.vercel.app
trackasone.me
track-as-one-git-main-joshxfi.vercel.app
trackasone.vercel.app