Skip to content

Commit

Permalink
Display toast if insufficient permissions to access page (#50)
Browse files Browse the repository at this point in the history
# Display toast if insufficient permissions to access page

## ♻️ Current situation & Problem
User is redirected without any feedback. Just for UX clarify, we need
users to know why redirection happened.

Closes #21 


## ⚙️ Release Notes 
* Display toast if insufficient permissions to access page


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
arkadiuszbachorski and PSchmiedmayer authored Sep 17, 2024
1 parent 190d2ad commit 6a16d8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
deployfirebase:
name: Deploy Firebase Project
needs: [buildandtest, determineenvironment, vars]
uses: StanfordBDHG/.github/.github/workflows/firebase-deploy.yml@envFirebase2
uses: StanfordBDHG/.github/.github/workflows/firebase-deploy.yml@v2
permissions:
contents: read
with:
Expand Down
5 changes: 4 additions & 1 deletion modules/firebase/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
getDocumentsRefs,
} from '@/modules/firebase/utils'
import { queryClient } from '@/modules/query/queryClient'
import { routes } from '@/modules/routes'
import { toast } from '@/packages/design-system/src/components/Toaster'

const firebaseApp = initializeApp(firebaseConfig)

Expand Down Expand Up @@ -68,6 +70,7 @@ export const getCurrentUser = async () => {
export const ensureType = async (types: UserType[]) => {
const type = await getCurrentUserType()
if (!types.includes(type)) {
throw redirect({ to: '/' })
toast.error(`You don't have permissions to access this page`)
throw redirect({ to: routes.home })
}
}

0 comments on commit 6a16d8d

Please sign in to comment.