Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with HMI not getting fetched correctly #447

Merged
merged 3 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/api/hatAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ export const newUserAccessToken = (pda: string, username: string, password: stri
return get<{ accessToken: string }>(path, { headers: headers });
};

export const recoverPassword = (body: { email: string }) => {
const path = `/control/v2/auth/passwordReset`;
export const recoverPassword = (pda: string, body: { email: string }) => {
const path = `https://${pda}/control/v2/auth/passwordReset`;
const headers = { 'Content-Type': 'application/json' };

//todo create new post function to accept headers, body
return post(path, {}, { method: 'post', headers: headers, body: JSON.stringify(body) });
};

Expand All @@ -37,8 +36,8 @@ export const getPublicProfile = (path: string) => {
return get<BundleValues>(path, { method: 'get', headers });
};

export const resetPassword = (resetToken: string, body: { newPassword: string }) => {
const path = `/control/v2/auth/passwordreset/confirm/${resetToken}`;
export const resetPassword = (pda: string, resetToken: string, body: { newPassword: string }) => {
const path = `https://${pda}/control/v2/auth/passwordreset/confirm/${resetToken}`;
const headers = { 'Content-Type': 'application/json' };

return post(path, {}, { method: 'post', headers: headers, body: JSON.stringify(body) });
Expand Down
52 changes: 20 additions & 32 deletions src/app/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ const HatClaim = React.lazy(
),
);

const Login = React.lazy(
() =>
import(
/* webpackChunkName: "user_login" */
'../components/user/Login'
),
);

const Feed = React.lazy(
() =>
import(
Expand All @@ -51,14 +43,6 @@ const HatLogin = React.lazy(
),
);

const PasswordRecover = React.lazy(
() =>
import(
/* webpackChunkName: "password_recover" */
'../components/user/PasswordRecover'
),
);

const AuthLogin = React.lazy(
() =>
import(
Expand Down Expand Up @@ -181,18 +165,6 @@ const AppRouter = () => (
<LandingLoginPage />
</LayoutRoute>

<LayoutRoute path="/hat/claim/:claimToken">
<HatClaim />
</LayoutRoute>

<LayoutRoute path="/user/login/">
<Login />
</LayoutRoute>

<LayoutRoute path="/user/password/recover">
<PasswordRecover />
</LayoutRoute>

<LayoutRoute path="/auth/login" issuedByFooter footerBackgroundColor="#fff">
<AuthLogin />
</LayoutRoute>
Expand All @@ -209,14 +181,30 @@ const AppRouter = () => (
<AuthVerifyEmail />
</LayoutRoute>

<PrivateLayoutRoute path={'/hatlogin'}>
<HatLogin />
</PrivateLayoutRoute>

<PrivateLayoutRoute path={'/auth/oauth'} newAuth issuedByFooter footerBackgroundColor="#fff">
<Oauth />
</PrivateLayoutRoute>


{/*
The following routes are deprecated.
*/}
<LayoutRoute path="/hat/claim/:claimToken">
<HatClaim />
</LayoutRoute>

<LayoutRoute path="/user/login/">
<AuthLogin />
</LayoutRoute>

<LayoutRoute path="/user/password/recover">
<AuthRecoverPassword />
</LayoutRoute>

<PrivateLayoutRoute path={'/hatlogin'}>
<HatLogin />
</PrivateLayoutRoute>

<PrivateLayoutRoute path={'/hat-setup-login'}>
<HatLogin />
</PrivateLayoutRoute>
Expand Down
4 changes: 2 additions & 2 deletions src/app/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Query = {
redirect_uri?: string;
};

export function PrivateRoute({ children, newAuth, ...rest }: OwnProps) {
export function PrivateRoute({ children, ...rest }: OwnProps) {
const isAuthenticated = useSelector(selectIsAuthenticated);
// TODO Add the type to the state useState<Query>
const [query, setQuery] = useState({});
Expand Down Expand Up @@ -54,7 +54,7 @@ export function PrivateRoute({ children, newAuth, ...rest }: OwnProps) {
) : (
<DelayedRedirect
to={{
pathname: newAuth ? '/auth/login' : '/user/login',
pathname: '/auth/login',
state: { from: location, query: query },
}}
delay={100}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Landing/LandingLoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Input } from 'hmi';
import { pdaLookupWithEmail } from '../../services/HattersService';
import { PdaLookupResponse } from '../../types/Hatters';
import { config } from '../../app.config';
import { useHistory } from 'react-router-dom';
import { Link, useHistory } from 'react-router-dom';
import { newUserAccessToken } from '../../api/hatAPI';
import { loginWithToken } from '../../features/authentication/authenticationSlice';
import { HatClientService } from '../../services/HatClientService';
import Cookies from 'js-cookie';
import { useDispatch } from 'react-redux';
import FormatMessage from "../../features/messages/FormatMessage";

const LandingLoginView: React.FC = () => {
const history = useHistory();
Expand Down Expand Up @@ -101,6 +102,10 @@ const LandingLoginView: React.FC = () => {
<button className="ds-hmi-btn ds-hmi-btn-primary" onClick={onLogin}>
Login
</button>

<Link className={'auth-login-btn-link'} to={'/auth/recover-password'}>
<FormatMessage id={'ds.auth.login.forgotPassword'} />
</Link>
</>
)}

Expand Down
140 changes: 0 additions & 140 deletions src/components/user/Login/Login.scss

This file was deleted.

Loading