* WIP * Chunk names * Add auth call * add auth * WIP * Auth management setup * fix a test * fix cypress machine count * some more changes * fix header link * check for auth * fix import * fix imports * Use auth class * WIP * Better loading * Remove unused * Remove qs * Auth loader * Redirect for login * Third part auth * 404 redirects * 404 page handling * Adding custom docker image for performance fixes * Correcting the workflow to get package step to run * Clean up * lazy auth load * remove assertions from delete app and logout calls * remove github workflow changes * roll back lazy auth * Error handling * test editor chunk suspense * Show header in editor before initialization * Changes for app view * Login header fixes * Loader fixes * Fix base login routes Co-authored-by: Arpit Mohan <arpit@appsmith.com>
36 lines
1.1 KiB
TypeScript
Executable File
36 lines
1.1 KiB
TypeScript
Executable File
import React from "react";
|
|
import { AppState } from "reducers";
|
|
import { getCurrentUser, getUserAuthError } from "selectors/usersSelectors";
|
|
import { connect } from "react-redux";
|
|
import { ANONYMOUS_USERNAME, User } from "constants/userConstants";
|
|
import { Redirect } from "react-router";
|
|
import { APPLICATIONS_URL, AUTH_LOGIN_URL, BASE_URL } from "constants/routes";
|
|
import PageLoadingBar from "pages/common/PageLoadingBar";
|
|
import ServerUnavailable from "pages/common/ServerUnavailable";
|
|
|
|
type Props = {
|
|
user?: User;
|
|
authError: string;
|
|
};
|
|
|
|
const LandingScreen = (props: Props) => {
|
|
if (props.user && window.location.pathname === BASE_URL) {
|
|
if (props.user.email === ANONYMOUS_USERNAME) {
|
|
return <Redirect to={AUTH_LOGIN_URL} />;
|
|
} else {
|
|
return <Redirect to={APPLICATIONS_URL} />;
|
|
}
|
|
}
|
|
if (props.authError && props.authError.length) {
|
|
return <ServerUnavailable />;
|
|
}
|
|
return <PageLoadingBar />;
|
|
};
|
|
|
|
const mapStateToProps = (state: AppState) => ({
|
|
user: getCurrentUser(state),
|
|
authError: getUserAuthError(state),
|
|
});
|
|
|
|
export default connect(mapStateToProps)(LandingScreen);
|