-
Notifications
You must be signed in to change notification settings - Fork 56
New page access denied page instead of something went wrong #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
76db7c9
New page access denied if do not have board access
Rajat-Dabade 5c65196
Added access denied page
Rajat-Dabade f4fdfae
Fix the theme issue
Rajat-Dabade e618067
Access denied on websocket
Rajat-Dabade 3d5f980
Merge branch 'main' into new-page-access-denied
Rajat-Dabade 69695f6
Clearing lastboard and view id after back to home btn clicked
Rajat-Dabade 1842680
Clearing localstorage when error message is access denied
Rajat-Dabade 7ffa077
for non admin redirect to access denied page if not have access
Rajat-Dabade fed57cd
Merge branch 'main' into new-page-access-denied
mattermost-build cd0b61b
Check for duplicate calls to loadOrJoinBoard on initial mount
Rajat-Dabade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
| .AccessDeniedPage { | ||
| height: 100%; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
|
|
||
| > div { | ||
| display: flex; | ||
| align-items: center; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .title { | ||
| color: var(--center-channel-color, #3F4350); | ||
| text-align: center; | ||
| font-family: Metropolis; | ||
| font-size: 28px; | ||
| font-style: normal; | ||
| font-weight: 600; | ||
| line-height: 36px; | ||
| margin-bottom: 8px; | ||
| } | ||
|
|
||
| .subtitle { | ||
| color: rgba(var(--center-channel-color-rgb), 0.75); | ||
| text-align: center; | ||
| font-family: "Open Sans"; | ||
| font-size: 14px; | ||
| font-style: normal; | ||
| font-weight: 400; | ||
| line-height: 20px; | ||
| max-width: 600px; | ||
| } | ||
|
|
||
| svg { | ||
| margin: 24px 0; | ||
| } | ||
| } |
This file contains hidden or 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,88 @@ | ||
| // Copyright (c) 2020-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import React, {useCallback} from 'react' | ||
| import {useHistory, useLocation} from 'react-router-dom' | ||
| import {FormattedMessage, useIntl} from 'react-intl' | ||
|
|
||
| import Button from '../widgets/buttons/button' | ||
| import './accessDeniedPage.scss' | ||
|
|
||
| import {setGlobalError} from '../store/globalError' | ||
| import {useAppDispatch} from '../store/hooks' | ||
| import {UserSettings} from '../userSettings' | ||
| import AccessDeniedIllustration from '../svg/access-denied-illustation' | ||
|
|
||
| const clearLastBoardAndViewIds = () => { | ||
| const lastTeamId = UserSettings.lastTeamId | ||
| if (lastTeamId) { | ||
| const lastBoardId = UserSettings.lastBoardId[lastTeamId] | ||
| if (lastBoardId) { | ||
| UserSettings.setLastViewId(lastBoardId, null) | ||
| } | ||
| UserSettings.setLastBoardID(lastTeamId, null) | ||
| } | ||
| } | ||
|
|
||
| const AccessDeniedPage = () => { | ||
| const history = useHistory() | ||
| const location = useLocation() | ||
| const intl = useIntl() | ||
| const dispatch = useAppDispatch() | ||
|
|
||
| const handleBackToHome = useCallback(() => { | ||
| // Clear any error state before navigating | ||
| dispatch(setGlobalError('')) | ||
|
|
||
| // Clear last board/view IDs as a precaution to prevent redirect loops. | ||
| const referrerPath = new URLSearchParams(location.search).get('r') | ||
| if (referrerPath) { | ||
| try { | ||
| const pathParts = decodeURIComponent(referrerPath).split('/').filter(Boolean) | ||
| if (pathParts[0] === 'team' && pathParts.length >= 3) { | ||
| const teamId = pathParts[1] | ||
| const boardId = pathParts[2] | ||
| UserSettings.setLastBoardID(teamId, null) | ||
| UserSettings.setLastViewId(boardId, null) | ||
| } | ||
| } catch { | ||
| clearLastBoardAndViewIds() | ||
| } | ||
| } else { | ||
| clearLastBoardAndViewIds() | ||
| } | ||
|
|
||
| // Always navigate to home, not back to the board that caused the error | ||
| history.push('/') | ||
| }, [history, dispatch, location.search]) | ||
|
|
||
| return ( | ||
| <div className='AccessDeniedPage'> | ||
| <div> | ||
| <AccessDeniedIllustration/> | ||
| <div className='title'> | ||
| <FormattedMessage | ||
| id='accessDenied.page.title' | ||
| defaultMessage={'You don’t have access to this board'} | ||
| /> | ||
| </div> | ||
| <div className='subtitle'> | ||
| <FormattedMessage | ||
| id='accessDenied.page.subtitle' | ||
| defaultMessage={'This board is private or has restricted permissions.'} | ||
| /> | ||
| </div> | ||
| <br/> | ||
| <Button | ||
| filled={true} | ||
| size='large' | ||
| onClick={handleBackToHome} | ||
| > | ||
| {intl.formatMessage({id: 'accessDenied.back-to-home', defaultMessage: 'Back to your boards'})} | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default React.memo(AccessDeniedPage) | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we, as precaution, clear out the last board and view IDs here? What happens if local storage contains last board/view ID of a board user doesn't have access to. I know we are clearing those before sending the user to this page, but maybe just to be extra careful, we could clear them here as well.