Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-10573 Add error page if user doesn't authorize Mattermost for OAuth (
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhealey authored and grundleborg committed Sep 14, 2018
1 parent e4eacad commit acbd391
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/error_page/error_message.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ export default function ErrorMessage({type, message, service}) {
</div>
);
break;
case ErrorPageTypes.OAUTH_ACCESS_DENIED:
errorMessage = (
<p>
<FormattedMessage
id='error.oauth_access_denied'
defaultMessage='You must authorize Mattermost to log in with {service}.'
values={{
service,
}}
/>
</p>
);
break;
case ErrorPageTypes.PAGE_NOT_FOUND:
default:
errorMessage = (
Expand Down
9 changes: 9 additions & 0 deletions components/error_page/error_page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ export default class ErrorPage extends React.PureComponent {
/>
</Link>
);
} else if (type === ErrorPageTypes.OAUTH_ACCESS_DENIED || type === ErrorPageTypes.OAUTH_MISSING_CODE) {
backButton = (
<Link to='/'>
<FormattedMessage
id='error.generic.link_login'
defaultMessage='Back to login page'
/>
</Link>
);
} else {
backButton = (
<Link to='/'>
Expand Down
8 changes: 8 additions & 0 deletions components/error_page/error_title.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export default function ErrorTitle({type, title}) {
/>
);
break;
case ErrorPageTypes.OAUTH_ACCESS_DENIED:
errorTitle = (
<FormattedMessage
id='error.oauth_access_denied.title'
defaultMessage='Authorization Error'
/>
);
break;
case ErrorPageTypes.OAUTH_MISSING_CODE:
errorTitle = (
<FormattedMessage
Expand Down
3 changes: 3 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,7 @@
"error.channel_not_found.message": "The channel you're requesting is private or does not exist. Please contact an Administrator to be added to the channel.",
"error.channel_not_found.title": "Channel Not Found",
"error.generic.link": "Back to {siteName}",
"error.generic.link_login": "Back to login page",
"error.generic.link_message": "Back to {siteName}",
"error.generic.message": "An error has occurred.",
"error.generic.title": "Error",
Expand All @@ -1879,6 +1880,8 @@
"error.not_found.link_message": "Back to Mattermost",
"error.not_found.message": "The page you were trying to reach does not exist",
"error.not_found.title": "Page not found",
"error.oauth_access_denied": "You must authorize Mattermost to log in with {service}.",
"error.oauth_access_denied.title": "Authorization Error",
"error.oauth_missing_code": "The service provider {service} did not provide an authorization code in the redirect URL.",
"error.oauth_missing_code.forum": "If you reviewed the above and are still having trouble with configuration, you may post in our {link} where we'll be happy to help with issues during setup.",
"error.oauth_missing_code.forum.link": "Troubleshooting forum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ exports[`components/error_page/ErrorMessage should match snapshot, no type nor m
</p>
`;

exports[`components/error_page/ErrorMessage should match snapshot, oauth_access_denied type 1`] = `
<p>
<FormattedMessage
defaultMessage="You must authorize Mattermost to log in with {service}."
id="error.oauth_access_denied"
values={
Object {
"service": "Gitlab",
}
}
/>
</p>
`;

exports[`components/error_page/ErrorMessage should match snapshot, oauth_missing_code type 1`] = `
<div>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ exports[`components/error_page/ErrorTitle should match snapshot, no type but wit

exports[`components/error_page/ErrorTitle should match snapshot, no type nor title 1`] = `"Error"`;

exports[`components/error_page/ErrorTitle should match snapshot, oauth_access_denied type 1`] = `
<FormattedMessage
defaultMessage="Authorization Error"
id="error.oauth_access_denied.title"
values={Object {}}
/>
`;

exports[`components/error_page/ErrorTitle should match snapshot, oauth_missing_code type 1`] = `
<FormattedMessage
defaultMessage="Mattermost needs your help"
Expand Down
9 changes: 9 additions & 0 deletions tests/components/error_page/error_message.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ describe('components/error_page/ErrorMessage', () => {
expect(wrapper).toMatchSnapshot();
});

test('should match snapshot, oauth_access_denied type', () => {
const props = {...baseProps, type: ErrorPageTypes.OAUTH_ACCESS_DENIED, service: 'Gitlab'};
const wrapper = shallow(
<ErrorMessage {...props}/>
);

expect(wrapper).toMatchSnapshot();
});

test('should match snapshot, page_not_found type', () => {
const props = {...baseProps, type: ErrorPageTypes.PAGE_NOT_FOUND};
const wrapper = shallow(
Expand Down
9 changes: 9 additions & 0 deletions tests/components/error_page/error_title.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ describe('components/error_page/ErrorTitle', () => {
expect(wrapper).toMatchSnapshot();
});

test('should match snapshot, oauth_access_denied type', () => {
const props = {...baseProps, type: ErrorPageTypes.OAUTH_ACCESS_DENIED};
const wrapper = shallow(
<ErrorTitle {...props}/>
);

expect(wrapper).toMatchSnapshot();
});

test('should match snapshot, page_not_found type', () => {
const props = {...baseProps, type: ErrorPageTypes.PAGE_NOT_FOUND};
const wrapper = shallow(
Expand Down
1 change: 1 addition & 0 deletions utils/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ export const StoragePrefixes = {

export const ErrorPageTypes = {
LOCAL_STORAGE: 'local_storage',
OAUTH_ACCESS_DENIED: 'oauth_access_denied',
OAUTH_MISSING_CODE: 'oauth_missing_code',
PAGE_NOT_FOUND: 'page_not_found',
PERMALINK_NOT_FOUND: 'permalink_not_found',
Expand Down

0 comments on commit acbd391

Please sign in to comment.