Skip to content
Open
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
3 changes: 2 additions & 1 deletion packages/auth/src/loginWithRocketChatOAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const loginWithRocketChatOAuth = async (config: { api: Api }) => {
width=800,height=600,left=-1000,top=-1000,rel=opener`;
const popup = window.open(authorizeUrl, "Login", params);

return new Promise<any>((resolve) => {
return new Promise<any>((resolve, reject) => {
if (popup) {
const onMessage = async (e: MessageEvent) => {
if (e.origin !== new URL(config.api.baseUrl).origin) {
Expand All @@ -64,6 +64,7 @@ width=800,height=600,left=-1000,top=-1000,rel=opener`;
if (popup.closed) {
clearInterval(checkInterval);
window.removeEventListener("message", onMessage);
reject(new Error("OAuth login cancelled"));
}
}, 1000);
} else {
Expand Down