Skip to content

Commit

Permalink
Implementing login process using ReCodEx temp token.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Dec 30, 2024
1 parent dbd8d10 commit 1c7409d
Show file tree
Hide file tree
Showing 54 changed files with 157 additions and 1,069 deletions.
2 changes: 1 addition & 1 deletion bin/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import fs from 'fs';
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory

const WEBPACK_DEV_SERVER_PORT = process.env.WEBPACK_DEV_SERVER_PORT || 8081;
const WEBPACK_DEV_SERVER_PORT = process.env.WEBPACK_DEV_SERVER_PORT || 8085;
const fileConfig = fs.readFileSync('etc/env.json', 'utf8');
const parsedConfig = JSON.parse(fileConfig);
const PORT = parsedConfig.PORT;
Expand Down
4 changes: 2 additions & 2 deletions etc/env.json.devel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"PORT": 8080,
"API_BASE": "https://recodex-devel.ms.mff.cuni.cz:4000/v1",
"PORT": 8084,
"API_BASE": "https://recodex-devel.ms.mff.cuni.cz:4004",
"TITLE": "SIS-CodEx",
"SKIN": "danger",
"URL_PATH_PREFIX": "",
Expand Down
4 changes: 2 additions & 2 deletions etc/env.json.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"PORT": 8080,
"API_BASE": "https://recodex.base.domain/api/v1",
"API_BASE": "https://recodex.base.domain/api",
"TITLE": "SIS-CodEx",
"SKIN": "success",
"URL_PATH_PREFIX": "",
"PERSISTENT_TOKENS_KEY_PREFIX": "rex-sis"
"PERSISTENT_TOKENS_KEY_PREFIX": "rex-sis-devel"
}
6 changes: 3 additions & 3 deletions etc/env.json.local
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"PORT": 8080,
"API_BASE": "http://127.0.0.1:4000/v1",
"PORT": 8084,
"API_BASE": "http://127.0.0.1:4004",
"TITLE": "SIS-CodEx",
"SKIN": "warning",
"URL_PATH_PREFIX": "",
"PERSISTENT_TOKENS_KEY_PREFIX": "rex-sis-local"
"PERSISTENT_TOKENS_KEY_PREFIX": "rex-sis-devel"
}
8 changes: 0 additions & 8 deletions etc/env.json.test

This file was deleted.

4 changes: 2 additions & 2 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';

import { configureOurStore } from './redux/store.js';
import { getToken, getInstanceId } from './redux/middleware/authMiddleware.js';
import { getToken } from './redux/middleware/authMiddleware.js';
import { getLang } from './redux/middleware/langMiddleware.js';
import App from './containers/App/index.js';

Expand Down Expand Up @@ -66,7 +66,7 @@ if (ini) {
});
}

const store = configureOurStore(state, getToken(), getInstanceId(), getLang());
const store = configureOurStore(state, getToken(), getLang());

const container = document.getElementById('root');
const root = createRoot(container);
Expand Down
4 changes: 0 additions & 4 deletions src/components/Users/UsersName/FailedUsersName.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { FailedAvatar } from '../../widgets/Avatar';

import * as styles from './usersName.less';

const FailedUsersName = ({ size = 25 }) => (
<span className={styles.wrapper}>
<span className={styles.avatar}>
<FailedAvatar size={size} />
</span>
<span style={{ lineHeight: `${size}px` }}>
<FormattedMessage id="generic.loading" defaultMessage="Loading..." />
</span>
Expand Down
4 changes: 0 additions & 4 deletions src/components/Users/UsersName/LoadingUsersName.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { LoadingAvatar } from '../../widgets/Avatar';

import * as styles from './usersName.less';

const LoadingUsersName = ({ size = 22 }) => (
<span className={styles.wrapper}>
<span className={styles.avatar}>
<LoadingAvatar light size={size} />
</span>
<span style={{ lineHeight: `${size}px` }}>
<FormattedMessage id="generic.loading" defaultMessage="Loading..." />
</span>
Expand Down
10 changes: 0 additions & 10 deletions src/components/Users/UsersName/UsersName.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { FormattedMessage } from 'react-intl';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { lruMemoize } from 'reselect';

import AvatarContainer from '../../../containers/AvatarContainer/AvatarContainer.js';
import { UserRoleIcon } from '../../helpers/usersRoles.js';
import Icon, { MailIcon, BanIcon } from '../../icons';
import withLinks from '../../../helpers/withLinks.js';
Expand Down Expand Up @@ -42,12 +41,10 @@ const assembleName = ({ titlesBeforeName = '', firstName, lastName, titlesAfterN

const UsersName = ({
id,
avatarUrl,
name,
size = null,
large = false,
link = false,
noAvatar = false,
privateData = null,
showEmail = null,
showExternalIdentifiers = false,
Expand All @@ -65,11 +62,6 @@ const UsersName = ({

return (
<span className={styles.wrapper}>
{(!privateData || privateData.isAllowed) && !noAvatar && (
<span className={styles.avatar}>
<AvatarContainer avatarUrl={avatarUrl} fullName={fullName} firstName={name.firstName} size={size} />
</span>
)}
<span style={userNameStyle(size, large)}>
{privateData && !privateData.isAllowed && (
<BanIcon
Expand Down Expand Up @@ -179,12 +171,10 @@ UsersName.propTypes = {
lastName: PropTypes.string.isRequired,
titlesAfterName: PropTypes.string,
}).isRequired,
avatarUrl: PropTypes.string,
privateData: PropTypes.object,
size: PropTypes.number,
large: PropTypes.bool,
link: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.bool]),
noAvatar: PropTypes.bool,
showEmail: PropTypes.string,
showExternalIdentifiers: PropTypes.bool,
showRoleIcon: PropTypes.bool,
Expand Down
6 changes: 0 additions & 6 deletions src/components/Users/UsersName/usersName.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@
white-space: initial;
}
}

.avatar {
margin-right: 8px;
vertical-align: text-top;
line-height: 100%;
}
23 changes: 0 additions & 23 deletions src/components/helpers/exams.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/helpers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const createUserNameComparator = locale => (u1, u2) => {
return (
u1.name.lastName.localeCompare(u2.name.lastName, locale) ||
u1.name.firstName.localeCompare(u2.name.firstName, locale) ||
(u1.privateData && u2.privateData && u1.privateData.email.localeCompare(u2.privateData.email, locale)) || // email is used in rare cases when two users have the same name
u1.email.localeCompare(u2.email, locale) || // email is used in rare cases when two users have the same name
u1.id.localeCompare(u2.id) // ultimate fallback (since email may not be visible to regular users)
);
};
2 changes: 0 additions & 2 deletions src/components/layout/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class Header extends Component {

Header.propTypes = {
isLoggedIn: PropTypes.bool,
toggleSidebarSize: PropTypes.func.isRequired,
toggleSidebarVisibility: PropTypes.func.isRequired,
currentLang: PropTypes.string.isRequired,
setLang: PropTypes.func.isRequired,
availableLangs: PropTypes.array,
Expand Down
54 changes: 0 additions & 54 deletions src/components/layout/Sidebar/Admin.js

This file was deleted.

83 changes: 6 additions & 77 deletions src/components/layout/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,17 @@ import MenuTitle from '../../widgets/Sidebar/MenuTitle';
import MenuItem from '../../widgets/Sidebar/MenuItem';
import { LoadingIcon } from '../../icons';
import { getJsData } from '../../../redux/helpers/resourceManager';
import { isSupervisorRole, isEmpoweredSupervisorRole, isSuperadminRole } from '../../helpers/usersRoles.js';
import { isSupervisorRole, isSuperadminRole } from '../../helpers/usersRoles.js';
import withLinks from '../../../helpers/withLinks.js';
import { getExternalIdForCAS } from '../../../helpers/cas.js';
import { getConfigVar } from '../../../helpers/config.js';
import Admin from './Admin.js';

import './sidebar.css';

const URL_PREFIX = getConfigVar('URL_PATH_PREFIX');

const getUserData = lruMemoize(user => getJsData(user));

const Sidebar = ({
pendingFetchOperations,
loggedInUser,
effectiveRole = null,
currentUrl,
links: {
HOME_URI,
FAQ_URL,
LOGIN_URI,
REGISTRATION_URI,
DASHBOARD_URI,
EXERCISES_URI,
PIPELINES_URI,
ARCHIVE_URI,
SIS_INTEGRATION_URI,
},
}) => {
const Sidebar = ({ pendingFetchOperations, loggedInUser, currentUrl, links: { HOME_URI } }) => {
const user = getUserData(loggedInUser);

return (
Expand Down Expand Up @@ -84,14 +66,7 @@ const Sidebar = ({
title={<FormattedMessage id="app.sidebar.menu.signIn" defaultMessage="Sign in" />}
icon="sign-in-alt"
currentPath={currentUrl}
link={LOGIN_URI}
/>
<MenuItem
title={<FormattedMessage id="app.sidebar.menu.createAccount" defaultMessage="Create account" />}
isActive={false}
icon="user-plus"
currentPath={currentUrl}
link={REGISTRATION_URI}
link={HOME_URI}
/>
</ul>
)}
Expand All @@ -104,58 +79,13 @@ const Sidebar = ({
role="menu"
data-accordion="false">
<MenuTitle title={<FormattedMessage id="app.sidebar.menu.title" defaultMessage="Menu" />} />
<MenuItem
title={<FormattedMessage id="app.sidebar.menu.dashboard" defaultMessage="Dashboard" />}
icon="tachometer-alt"
currentPath={currentUrl}
link={DASHBOARD_URI}
/>

{isSupervisorRole(effectiveRole) && (
<MenuItem
title={<FormattedMessage id="app.sidebar.menu.exercises" defaultMessage="Exercises" />}
icon="puzzle-piece"
currentPath={currentUrl}
link={EXERCISES_URI}
/>
)}
<MenuItem title="TODO" icon="tachometer-alt" currentPath={currentUrl} link="TODO" />

{isEmpoweredSupervisorRole(effectiveRole) && (
<MenuItem
title={<FormattedMessage id="app.sidebar.menu.pipelines" defaultMessage="Pipelines" />}
icon="random"
currentPath={currentUrl}
link={PIPELINES_URI}
/>
)}

<MenuItem
title={<FormattedMessage id="app.sidebar.menu.archive" defaultMessage="Archive" />}
icon="archive"
currentPath={currentUrl}
link={ARCHIVE_URI}
/>

{Boolean(getExternalIdForCAS(user)) && (
<MenuItem
icon="id-badge"
title={<FormattedMessage id="app.sidebar.menu.admin.sis" defaultMessage="SIS Integration" />}
currentPath={currentUrl}
link={SIS_INTEGRATION_URI}
/>
)}

<MenuItem
title={<FormattedMessage id="app.sidebar.menu.faq" defaultMessage="FAQ" />}
icon={['far', 'question-circle']}
link={FAQ_URL}
currentPath={currentUrl}
/>
{isSupervisorRole(user.role) && <></>}
{isSuperadminRole(user.role) && <></>}
</ul>
</>
)}

{isSuperadminRole(effectiveRole) && <Admin currentUrl={currentUrl} />}
</nav>
</div>
</div>
Expand All @@ -166,7 +96,6 @@ const Sidebar = ({
Sidebar.propTypes = {
pendingFetchOperations: PropTypes.bool,
loggedInUser: ImmutablePropTypes.map,
effectiveRole: PropTypes.string,
currentUrl: PropTypes.string,
links: PropTypes.object,
};
Expand Down
21 changes: 0 additions & 21 deletions src/components/widgets/Avatar/Avatar.js

This file was deleted.

Loading

0 comments on commit 1c7409d

Please sign in to comment.