Skip to content

Commit a9ccb1f

Browse files
committed
Handle error state when initial authentication against ReCodEx fails.
1 parent 86a4a06 commit a9ccb1f

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

src/components/Groups/CoursesGroupsList/CoursesGroupsList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const CoursesGroupsList = ({
158158
<BindIcon gapRight />
159159
<FormattedMessage
160160
id="app.coursesGroupsList.bind"
161-
defaultMessage="Bind Existing Group"
161+
defaultMessage="Bind with Existing Group"
162162
/>
163163
</Button>
164164
)}

src/locales/cs.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"app.box.highlighterExplanation": "Tento panel je zvýrazněný. Klikněte pro vrácení do normálního stavu.",
4848
"app.confirm.no": "Ne",
4949
"app.confirm.yes": "Ano",
50-
"app.coursesGroupsList.bind": "Svázat existující skupinu",
50+
"app.coursesGroupsList.bind": "Svázat s existující skupinou",
5151
"app.coursesGroupsList.create": "Vytvořit novou skupinu",
5252
"app.coursesGroupsList.firstWeekEven": "sudé týdny",
5353
"app.coursesGroupsList.firstWeekOdd": "liché týdny",
@@ -142,13 +142,14 @@
142142
"app.homepage.groupsStudentPage": "Připojte se ke skupinám, které odpovídají vašim zapsaným předmětům v SISu.",
143143
"app.homepage.groupsSuperadminPage": "Správa skupin a jejich atributů na nejvyšší úrovni (dostupné pouze hlavním administrátorům).",
144144
"app.homepage.groupsTeacherPage": "Vytvořte nebo přiřaďte skupiny pro vaše předměty ze SISu.",
145+
"app.homepage.loginFailed": "Ověření uživatele selhalo",
145146
"app.homepage.processingToken": "Probíhá zpracování přihlašovacího tokenu...",
146147
"app.homepage.processingTokenFailed": "Autentizační proces selhal.",
147148
"app.homepage.returnToReCodEx": "Návrat do ReCodExu...",
148149
"app.homepage.termsPage": "Správa semestrů a jejich souvisejících dat (kdy jsou aktivní pro studenty a učitele).",
149150
"app.homepage.title": "Rozšíření SIS-CodEx",
150151
"app.homepage.userPage": "Stránka s osobními údaji umožnujě synchronizovat uživatelský profil (jméno, tituly, email) s daty ze SISu.",
151-
"app.homepage.userSessionExpired": "Vaše uživatelská relace vypršela",
152+
"app.homepage.userSessionExpired": "Vaše uživatelská relace vypršela nebo jste se odhlásili",
152153
"app.homepage.userSessionExpiredInfo": "Musíte inicializovat novou relaci opětovným vstupem do této aplikace z ReCodExu.",
153154
"app.localizedTexts.validation.noLocalizedText": "Prosíme povolte alespoň jednu záložku s lokalizovanými texty.",
154155
"app.notifications.hideAll": "Pouze nové notifikace",

src/locales/en.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"app.box.highlighterExplanation": "This box is highlighted. Click to restore.",
4848
"app.confirm.no": "No",
4949
"app.confirm.yes": "Yes",
50-
"app.coursesGroupsList.bind": "Bind Existing Group",
50+
"app.coursesGroupsList.bind": "Bind with Existing Group",
5151
"app.coursesGroupsList.create": "Create New Group",
5252
"app.coursesGroupsList.firstWeekEven": "even weeks",
5353
"app.coursesGroupsList.firstWeekOdd": "odd weeks",
@@ -142,13 +142,14 @@
142142
"app.homepage.groupsStudentPage": "Join groups that correspond to your enrolled courses in SIS.",
143143
"app.homepage.groupsSuperadminPage": "Management of groups and their attributes at highest level (available to superadmins only).",
144144
"app.homepage.groupsTeacherPage": "Create or bind groups for your courses in SIS.",
145+
"app.homepage.loginFailed": "Authentication process failed",
145146
"app.homepage.processingToken": "Processing authentication token...",
146147
"app.homepage.processingTokenFailed": "Authentication process failed.",
147148
"app.homepage.returnToReCodEx": "Return to ReCodEx...",
148149
"app.homepage.termsPage": "Management of terms and their related dates (when they are active for students and teachers).",
149150
"app.homepage.title": "SiS-CodEx Extension",
150151
"app.homepage.userPage": "The personal data integration page allows updating ReCodEx user profile (name, titles, email) using data from SIS.",
151-
"app.homepage.userSessionExpired": "Your user session has expired",
152+
"app.homepage.userSessionExpired": "Your user session has expired or you have logged out",
152153
"app.homepage.userSessionExpiredInfo": "You need to initialize a new session by re-entering this application from ReCodEx.",
153154
"app.localizedTexts.validation.noLocalizedText": "Please enable at least one tab of localized texts.",
154155
"app.notifications.hideAll": "Only new notifications",
@@ -267,4 +268,4 @@
267268
"generic.operationFailed": "The operation has failed",
268269
"generic.reset": "Reset",
269270
"generic.save": "Save"
270-
}
271+
}

src/pages/Home/Home.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import Icon, {
2323
import Callout from '../../components/widgets/Callout';
2424

2525
import { setLang } from '../../redux/modules/app.js';
26-
import { login, logout } from '../../redux/modules/auth.js';
26+
import { login, logout, statusTypes as authStatusTypes } from '../../redux/modules/auth.js';
2727
import { fetchUserIfNeeded } from '../../redux/modules/users.js';
2828
import { loggedInUserSelector } from '../../redux/selectors/users.js';
29-
import { loggedInUserIdSelector } from '../../redux/selectors/auth.js';
29+
import { loggedInUserIdSelector, loginStatusSelector } from '../../redux/selectors/auth.js';
3030

3131
import { getReturnUrl, setReturnUrl } from '../../helpers/localStorage.js';
3232
import { knownLocalesNames } from '../../helpers/localizedData.js';
@@ -85,19 +85,27 @@ class Home extends Component {
8585
render() {
8686
const {
8787
loggedInUser,
88+
loginStatus,
8889
params: { token = null },
8990
links: { USER_URI, TERMS_URI, GROUPS_STUDENT_URI, GROUPS_TEACHER_URI, GROUPS_SUPERADMIN_URI },
9091
} = this.props;
9192

92-
if (!loggedInUser && !token) {
93+
if (!loggedInUser && (!token || loginStatus === authStatusTypes.LOGIN_FAILED)) {
9394
return (
9495
<PageContent
9596
icon={<HomeIcon />}
9697
title={<FormattedMessage id="app.homepage.title" defaultMessage="SiS-CodEx Extension" />}
9798
windowTitle={<FormattedMessage id="app.homepage.title" defaultMessage="SiS-CodEx Extension" />}>
9899
<Callout variant="warning" className="my-3">
99100
<h4>
100-
<FormattedMessage id="app.homepage.userSessionExpired" defaultMessage="Your user session has expired" />
101+
{!token ? (
102+
<FormattedMessage
103+
id="app.homepage.userSessionExpired"
104+
defaultMessage="Your user session has expired or you have logged out"
105+
/>
106+
) : (
107+
<FormattedMessage id="app.homepage.loginFailed" defaultMessage="Authentication process failed" />
108+
)}
101109
</h4>
102110
<p>
103111
<FormattedMessage
@@ -342,6 +350,7 @@ Home.propTypes = {
342350
}),
343351
loggedInUserId: PropTypes.string,
344352
loggedInUser: ImmutablePropTypes.map,
353+
loginStatus: PropTypes.string,
345354
loadAsync: PropTypes.func.isRequired,
346355
setLang: PropTypes.func.isRequired,
347356
login: PropTypes.func.isRequired,
@@ -353,6 +362,7 @@ export default connect(
353362
state => ({
354363
loggedInUserId: loggedInUserIdSelector(state),
355364
loggedInUser: loggedInUserSelector(state),
365+
loginStatus: loginStatusSelector(state),
356366
}),
357367
dispatch => ({
358368
loadAsync: userId => Home.loadAsync({ userId }, dispatch),

src/redux/selectors/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const accessTokenExpiration = createSelector(accessTokenSelector, token =
1515
);
1616
export const loggedInUserIdSelector = createSelector(getAuth, getLoggedInUserId);
1717

18-
export const loginStatusSelector = createSelector(getAuth, auth => auth.getIn(['status']));
18+
export const loginStatusSelector = createSelector(getAuth, auth => auth.getIn(['status', 'recodex']));
1919

2020
export const loginErrorSelector = createSelector(getAuth, auth => auth.getIn(['errors', 'recodex'])?.toJS() || null);
2121

0 commit comments

Comments
 (0)