From 5bff0840ee43f6aaf9a061b0e05f4f22ca38325f Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Sat, 29 Jul 2023 13:12:54 -0500 Subject: [PATCH] frontend ui configured. --- client/src/components/OIDC/OidcLogin.jsx | 7 ++++ client/src/components/OIDC/index.js | 3 ++ client/src/components/Root.jsx | 46 +++++++++++++++------ client/src/constants/Paths.js | 2 + client/src/containers/OidcLoginContainer.js | 26 ++++++++++++ client/src/locales/cs/core.js | 3 +- client/src/sagas/login/services/login.js | 8 +++- 7 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 client/src/components/OIDC/OidcLogin.jsx create mode 100644 client/src/components/OIDC/index.js create mode 100644 client/src/containers/OidcLoginContainer.js diff --git a/client/src/components/OIDC/OidcLogin.jsx b/client/src/components/OIDC/OidcLogin.jsx new file mode 100644 index 0000000..8995042 --- /dev/null +++ b/client/src/components/OIDC/OidcLogin.jsx @@ -0,0 +1,7 @@ +import React from 'react'; + +const OidcLogin = react.memo(() => { + return
test
; +}); + +export default OidcLogin; diff --git a/client/src/components/OIDC/index.js b/client/src/components/OIDC/index.js new file mode 100644 index 0000000..ef35774 --- /dev/null +++ b/client/src/components/OIDC/index.js @@ -0,0 +1,3 @@ +import OidcLogin from './OidcLogin'; + +export default OidcLogin; diff --git a/client/src/components/Root.jsx b/client/src/components/Root.jsx index a5671f9..2e4a931 100755 --- a/client/src/components/Root.jsx +++ b/client/src/components/Root.jsx @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { AuthProvider } from 'oidc-react'; import { Provider } from 'react-redux'; import { Route, Routes } from 'react-router-dom'; import { ReduxRouter } from '../lib/redux-router'; @@ -8,28 +9,47 @@ import Paths from '../constants/Paths'; import LoginContainer from '../containers/LoginContainer'; import CoreContainer from '../containers/CoreContainer'; import NotFound from './NotFound'; +import entryActions from '../entry-actions'; import 'react-datepicker/dist/react-datepicker.css'; import 'photoswipe/dist/photoswipe.css'; import 'easymde/dist/easymde.min.css'; import '../lib/custom-ui/styles.css'; - import '../styles.module.scss'; +import OidcLoginContainer from '../containers/OidcLoginContainer'; + +const oidcConfig = { + onSignIn: (user) => { + // Redirect? + entryActions.authenticate(user); + }, + authority: 'https://auth.jjakt.monster/realms/test-realm/', + clientId: 'planka-dev', + redirectUri: 'http://localhost:3000/OidcLogin', +}; function Root({ store, history }) { return ( - - - - } /> - } /> - } /> - } /> - } /> - } /> - - - + + + + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + + ); } diff --git a/client/src/constants/Paths.js b/client/src/constants/Paths.js index 6f0d666..60eba96 100755 --- a/client/src/constants/Paths.js +++ b/client/src/constants/Paths.js @@ -2,6 +2,7 @@ import Config from './Config'; const ROOT = `${Config.BASE_PATH}/`; const LOGIN = `${Config.BASE_PATH}/login`; +const OIDC_LOGIN = `${Config.BASE_PATH}/oidclogin`; const PROJECTS = `${Config.BASE_PATH}/projects/:id`; const BOARDS = `${Config.BASE_PATH}/boards/:id`; const CARDS = `${Config.BASE_PATH}/cards/:id`; @@ -12,4 +13,5 @@ export default { PROJECTS, BOARDS, CARDS, + OIDC_LOGIN, }; diff --git a/client/src/containers/OidcLoginContainer.js b/client/src/containers/OidcLoginContainer.js new file mode 100644 index 0000000..15083ad --- /dev/null +++ b/client/src/containers/OidcLoginContainer.js @@ -0,0 +1,26 @@ +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; + +import entryActions from '../entry-actions'; +import OidcLogin from '../components/OIDC'; + +const mapStateToProps = ({ + ui: { + authenticateForm: { data: defaultData, isSubmitting, error }, + }, +}) => ({ + defaultData, + isSubmitting, + error, +}); + +const mapDispatchToProps = (dispatch) => + bindActionCreators( + { + onAuthenticate: entryActions.authenticate, + onMessageDismiss: entryActions.clearAuthenticateError, + }, + dispatch, + ); + +export default connect(mapStateToProps, mapDispatchToProps)(OidcLogin); diff --git a/client/src/locales/cs/core.js b/client/src/locales/cs/core.js index 1fc870c..ec6b0e1 100644 --- a/client/src/locales/cs/core.js +++ b/client/src/locales/cs/core.js @@ -146,8 +146,7 @@ export default { subscribeToMyOwnCardsByDefault: 'Ve výchozím nastavení odebírat vlastní karty', taskActions_title: 'Akce na úkolu', tasks: 'Úkoly', - thereIsNoPreviewAvailableForThisAttachment: - 'Pro tuto přílohu není k dispozici žádný náhled', + thereIsNoPreviewAvailableForThisAttachment: 'Pro tuto přílohu není k dispozici žádný náhled', time: 'Čas', title: 'Titulek', userActions_title: 'Akce na uživateli', diff --git a/client/src/sagas/login/services/login.js b/client/src/sagas/login/services/login.js index 7bdf7f2..1d494aa 100644 --- a/client/src/sagas/login/services/login.js +++ b/client/src/sagas/login/services/login.js @@ -7,9 +7,13 @@ import { setAccessToken } from '../../../utils/access-token-storage'; export function* authenticate(data) { yield put(actions.authenticate(data)); - let accessToken; + let { accessToken } = data; try { - ({ item: accessToken } = yield call(api.createAccessToken, data)); + if (accessToken) { + // swap + } else { + ({ item: accessToken } = yield call(api.createAccessToken, data)); + } } catch (error) { yield put(actions.authenticate.failure(error)); return;