Skip to content

Commit

Permalink
Web: Refactoring asyn/promise calls
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySafronov authored Nov 3, 2021
1 parent 5d95340 commit baccb13
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions web/ASC.Web.Login/src/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,25 @@ const Form = (props) => {
const { error, confirmedEmail } = match.params;

const oAuthLogin = async (profile) => {
await thirdPartyLogin(profile)
.then(() => {
const redirectPath = localStorage.getItem("redirectPath");
try {
await thirdPartyLogin(profile);

if (redirectPath) {
localStorage.removeItem("redirectPath");
window.location.href = redirectPath;
}
})
.catch(() => {
toastr.error(
t("Common:ProviderNotConnected"),
t("Common:ProviderLoginError")
);
})
.finally(() => {
localStorage.removeItem("profile");
localStorage.removeItem("code");
});
const redirectPath = localStorage.getItem("redirectPath");

if (redirectPath) {
localStorage.removeItem("redirectPath");
window.location.href = redirectPath;
}
}
catch(e) {
toastr.error(
t("Common:ProviderNotConnected"),
t("Common:ProviderLoginError")
);
}

localStorage.removeItem("profile");
localStorage.removeItem("code");
};

useEffect(() => {
Expand Down

0 comments on commit baccb13

Please sign in to comment.