Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit d5bb06d

Browse files
bors[bot]rehandalal
andcommitted
Merge #226
226: Fix login error display r=peterbe a=rehandalal Fixes #225. r? Co-authored-by: Rehan Dalal <rehandalal@gmail.com>
2 parents ed7e9f5 + da6b6bd commit d5bb06d

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/components/App.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
import { Layout } from 'antd';
1+
import { Layout, notification } from 'antd';
22
import PropTypes from 'prop-types';
33
import React from 'react';
44
import { BrowserRouter, Link } from 'react-router-dom';
55
import { connect } from 'react-redux';
66

7-
import Error from './Error';
8-
import { getError } from 'console/state/auth/selectors';
9-
107
import AuthButton from 'console/components/auth/AuthButton';
118
import NavBar from 'console/components/navigation/NavBar';
129
import QueryActions from 'console/components/data/QueryActions';
1310
import QueryAuth0 from 'console/components/data/QueryAuth0';
1411
import AppRouter from 'console/components/AppRouter';
1512
import CircleLogo from 'console/components/svg/CircleLogo';
13+
import { getError } from 'console/state/auth/selectors';
14+
1615
const { Header } = Layout;
1716

1817
@connect((state, props) => ({
19-
error: getError(state),
18+
authError: getError(state),
2019
}))
2120
export default class App extends React.Component {
2221
static propTypes = {
23-
error: PropTypes.object,
22+
authError: PropTypes.object,
2423
};
2524

25+
componentDidUpdate() {
26+
const { authError } = this.props;
27+
28+
if (authError) {
29+
notification['error']({
30+
message: 'Authentication Error',
31+
description: `${authError.get('error')}: ${authError.get('errorDescription')}`,
32+
duration: 0,
33+
});
34+
}
35+
}
36+
2637
render() {
2738
return (
2839
<BrowserRouter>
@@ -48,8 +59,6 @@ export default class App extends React.Component {
4859

4960
<NavBar />
5061

51-
<Error error={this.props.error} />
52-
5362
<AppRouter />
5463
</Layout>
5564
</BrowserRouter>

src/components/Error.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/state/auth/selectors.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ export function getAccessToken(state, defaultsTo = null) {
66
return state.auth.session.get('accessToken', defaultsTo);
77
}
88

9+
/**
10+
* Gets the authentication error from the state
11+
*
12+
* @param state The current state
13+
* @param defaultsTo A fallback value
14+
* @returns {Immutable.Map({error: String, errorDescription: String})}
15+
*/
916
export function getError(state, defaultsTo = null) {
1017
return state.auth.session.get('error', defaultsTo);
1118
}

0 commit comments

Comments
 (0)