Web: Login: added authCallback, modified types

This commit is contained in:
Artem Tarasov 2022-08-22 15:09:03 +03:00
parent eba3f4ebe5
commit 31603541b1
2 changed files with 15 additions and 3 deletions

View File

@ -15,7 +15,7 @@ type WindowI18nType = {
declare global {
interface Window {
authCallback?: (profile: object) => {};
authCallback?: (profile: string) => {};
__ASC_INITIAL_LOGIN_STATE__: IInitialState;
initialI18nStoreASC: IInitialI18nStoreASC;
initialLanguage: string;

View File

@ -14,6 +14,9 @@ import { checkPwd } from "@docspace/common/desktop";
import { login } from "@docspace/common/utils/loginUtils";
import { oAuthLogin } from "../../helpers/utils";
import toastr from "@docspace/components/toast/toastr";
const organizationName = "ONLYOFFICE"; //TODO: Replace to API variant
interface ILoginFormProps {
isLoading: boolean;
setIsLoading: (isLoading: boolean) => void;
@ -59,6 +62,17 @@ const LoginForm: React.FC<ILoginFormProps> = ({
authCallback(profile);
}, []);
useEffect(() => {
document.title = `${t("Authorization")} ${organizationName}`; //TODO: implement the setDocumentTitle() utility in ASC.Web.Common
error && setErrorText(error);
confirmedEmail && setIdentifier(confirmedEmail);
focusInput();
window.authCallback = authCallback;
}, []);
const authCallback = async (profile: string) => {
const result = await oAuthLogin(profile);
if (!result) {
@ -111,10 +125,8 @@ const LoginForm: React.FC<ILoginFormProps> = ({
login(user, hash, session)
.then((res: string | object) => {
const redirectPath = localStorage.getItem("redirectPath");
console.log(res);
if (redirectPath) {
localStorage.removeItem("redirectPath");
console.log("here");
window.location.href = redirectPath;
return;
}