Skip to content
Closed
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
1 change: 1 addition & 0 deletions config/CN/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GITHUB_CLIENT_ID=9821657775fbc74773f1
WECHAT_APP_ID=wx1133c2153a45e9b8
AGORA_OAUTH_CLIENT_ID=flat-dev
GOOGLE_OAUTH_CLIENT_ID=273996094508-p97og69ojac5ja0khn1rvmi3tb7vgfgm.apps.googleusercontent.com
QQ_APP_ID=

CLOUD_STORAGE_OSS_ALIBABA_ACCESS_KEY=LTAI5t9Gb6tzQzzLmB6cTVf7
CLOUD_STORAGE_OSS_ALIBABA_BUCKET=flat-storage
Expand Down
1 change: 1 addition & 0 deletions config/CN/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GITHUB_CLIENT_ID=71a29285a437998bdfe0
WECHAT_APP_ID=wx96d522d69d384cce
AGORA_OAUTH_CLIENT_ID=flat
GOOGLE_OAUTH_CLIENT_ID=273996094508-2rpraucen77a1o5dul5ftrua5k3og157.apps.googleusercontent.com
QQ_APP_ID=

CLOUD_STORAGE_OSS_ALIBABA_ACCESS_KEY=LTAI5t9Gb6tzQzzLmB6cTVf7
CLOUD_STORAGE_OSS_ALIBABA_BUCKET=flat-storage
Expand Down
1 change: 1 addition & 0 deletions config/US/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GITHUB_CLIENT_ID=0ac608815326aead5db7
WECHAT_APP_ID=wx1133c2153a45e9b8
AGORA_OAUTH_CLIENT_ID=flat-dev
GOOGLE_OAUTH_CLIENT_ID=273996094508-p97og69ojac5ja0khn1rvmi3tb7vgfgm.apps.googleusercontent.com
QQ_APP_ID=

CLOUD_STORAGE_OSS_ALIBABA_ACCESS_KEY=LTAI5t9Gb6tzQzzLmB6cTVf7
CLOUD_STORAGE_OSS_ALIBABA_BUCKET=flat-storage
Expand Down
1 change: 1 addition & 0 deletions config/US/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GITHUB_CLIENT_ID=da83d7e14217594fba46
WECHAT_APP_ID=wx96d522d69d384cce
AGORA_OAUTH_CLIENT_ID=flat
GOOGLE_OAUTH_CLIENT_ID=273996094508-2rpraucen77a1o5dul5ftrua5k3og157.apps.googleusercontent.com
QQ_APP_ID=

CLOUD_STORAGE_OSS_ALIBABA_ACCESS_KEY=LTAI5t9Gb6tzQzzLmB6cTVf7
CLOUD_STORAGE_OSS_ALIBABA_BUCKET=flat-storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ export enum LoginPlatform {
Agora = "Agora",
Google = "Google",
Phone = "Phone",
QQ = "QQ",
}

export interface RemoveBindingPayload {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import wechatSVG from "./icons/wechat.svg";
import agoraSVG from "./icons/agora.svg";
import githubSVG from "./icons/github.svg";
import googleSVG from "./icons/google.svg";
import qqSVG from "./icons/qq.svg";
import "./index.less";

import React from "react";

export type LoginButtonProviderType = "wechat" | "github" | "agora" | "google";
export type LoginButtonProviderType = "wechat" | "github" | "agora" | "google" | "qq";

export interface LoginButtonProps {
provider: LoginButtonProviderType;
Expand All @@ -19,6 +20,7 @@ const svgDict: Record<LoginButtonProviderType, string> = {
agora: agoraSVG,
github: githubSVG,
google: googleSVG,
qq: qqSVG,
};

export const LoginButton: React.FC<LoginButtonProps> = ({ provider, text, onClick }) => {
Expand Down
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"begin-time": "Start time",
"join-and-book-by-room-uuid": "Can join and book by room ID",
"copy": "Copy",
"login-qq": "QQ",
"login-github": "GitHub",
"login-google": "Google",
"login-wechat": "WeChat",
Expand Down
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"room-type": "房间类型",
"begin-time": "开始时间",
"copy": "复制",
"login-qq": "QQ",
"login-wechat": "微信",
"login-github": "GitHub",
"login-google": "Google",
Expand Down
11 changes: 10 additions & 1 deletion packages/flat-pages/src/LoginPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { githubLogin } from "./githubLogin";
import { WeChatLogin } from "./WeChatLogin";
import { agoraLogin } from "./agoraLogin";
import { googleLogin } from "./googleLogin";
import { qqLogin } from "./qqLogin";
import { RouteNameType, usePushHistory, useURLParams } from "../utils/routes";
import { GlobalStoreContext, WindowsSystemBtnContext } from "../components/StoreProvider";
import { joinRoomHandler } from "../utils/join-room-handler";
Expand Down Expand Up @@ -113,6 +114,10 @@ export const LoginPage = observer(function LoginPage() {
loginDisposer.current = googleLogin(onLoginResult, windowsBtn);
return;
}
case "qq": {
loginDisposer.current = qqLogin(onLoginResult, windowsBtn);
return;
}
default: {
return;
}
Expand Down Expand Up @@ -155,7 +160,11 @@ export const LoginPage = observer(function LoginPage() {
bindingPhone={async (countryCode, phone, code) =>
wrap(bindingPhone(countryCode + phone, Number(code)).then(onBoundPhone))
}
buttons={[process.env.FLAT_REGION === "US" ? "google" : "wechat", "github"]}
buttons={
process.env.FLAT_REGION === "US"
? ["google", "github"]
: ["wechat", "qq", "github"]
}
cancelBindingPhone={() => setLoginResult(null)}
isBindingPhone={
NEED_BINDING_PHONE && (loginResult ? !loginResult.hasPhone : false)
Expand Down
47 changes: 47 additions & 0 deletions packages/flat-pages/src/LoginPage/qqLogin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { v4 as uuidv4 } from "uuid";
import { LoginExecutor } from "./utils";
import { QQ } from "../constants/process";
import { errorTips } from "flat-components";
import { FLAT_SERVER_LOGIN, setAuthUUID, loginProcess } from "@netless/flat-server-api";

export const qqLogin: LoginExecutor = (onSuccess, windowsBtn) => {
let timer = NaN;
const authUUID = uuidv4();

void (async () => {
try {
await setAuthUUID(authUUID);
} catch (err) {
errorTips(err);
}

windowsBtn
? windowsBtn.openExternalBrowser(getQqURL(authUUID, FLAT_SERVER_LOGIN.QQ_CALLBACK))
: void window.open(getQqURL(authUUID, FLAT_SERVER_LOGIN.QQ_CALLBACK));

const qqLoginProcessRequest = async (): Promise<void> => {
try {
const data = await loginProcess(authUUID);
if (!data.name) {
timer = window.setTimeout(qqLoginProcessRequest, 2000);
return;
}

onSuccess(data);
} catch (err) {
errorTips(err);
}
};

void qqLoginProcessRequest();
})();

return () => {
window.clearTimeout(timer);
};
};

export function getQqURL(authUUID: string, redirect_uri: string): string {
const redirectURL = encodeURIComponent(redirect_uri);
return `https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=${QQ.CLIENT_ID}&redirect_uri=${redirectURL}&state=${authUUID}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const defaultBindings: ListBindingsResult = {
apple: false,
github: false,
google: false,
qq: false,
};

export function useBindingList(): { bindings: ListBindingsResult; refresh: () => void } {
Expand Down
4 changes: 4 additions & 0 deletions packages/flat-pages/src/constants/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const GOOGLE = Object.freeze({
CLIENT_ID: process.env.GOOGLE_OAUTH_CLIENT_ID,
});

export const QQ = Object.freeze({
CLIENT_ID: process.env.QQ_APP_ID,
});

export const FLAT_DOWNLOAD_URL = process.env.FLAT_DOWNLOAD_URL;

export const PRIVACY_URL_CN = "https://flat.whiteboard.agora.io/privacy.html";
Expand Down
1 change: 1 addition & 0 deletions packages/flat-pages/src/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare namespace NodeJS {
GITHUB_CLIENT_ID: string;
GOOGLE_OAUTH_CLIENT_ID: string;

QQ_APP_ID: string;
WECHAT_APP_ID: string;
FLAT_SERVER_DOMAIN: string;
FLAT_WEB_DOMAIN: string;
Expand Down
1 change: 1 addition & 0 deletions packages/flat-server-api/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const FLAT_SERVER_LOGIN = {
GITHUB_CALLBACK: `https://${process.env.FLAT_SERVER_DOMAIN}/v1/login/github/callback?platform=web`,
GOOGLE_CALLBACK: `https://${process.env.FLAT_SERVER_DOMAIN}/v1/login/google/callback`,
WECHAT_CALLBACK: `https://${process.env.FLAT_SERVER_DOMAIN}/v1/login/weChat/web/callback`,
QQ_CALLBACK: `https://${process.env.FLAT_SERVER_DOMAIN}/v1/login/qq/callback?platform=web`,
} as const;

export const FLAT_SERVER_USER_BINDING = {
Expand Down
2 changes: 2 additions & 0 deletions packages/flat-server-api/src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export interface ListBindingsResult {
apple: boolean;
github: boolean;
google: boolean;
qq: boolean;
}

export async function listBindings(): Promise<ListBindingsResult> {
Expand Down Expand Up @@ -188,6 +189,7 @@ export enum LoginPlatform {
Agora = "Agora",
Google = "Google",
Phone = "Phone",
QQ = "QQ",
}

export interface RemoveBindingPayload {
Expand Down
1 change: 1 addition & 0 deletions web/flat-web/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare namespace NodeJS {
GITHUB_CLIENT_ID: string;
GOOGLE_OAUTH_CLIENT_ID: string;

QQ_APP_ID: string;
WECHAT_APP_ID: string;
FLAT_SERVER_DOMAIN: string;
FLAT_WEB_DOMAIN: string;
Expand Down