Refactor login method (#599)

* fix login form

* use github oauth device flow

* refactor login form

* mixin otp

* fix ui

* clean up code

* upgrade deps

* fix intl tel input
This commit is contained in:
an-lee
2024-05-13 08:42:48 +08:00
committed by GitHub
parent fcd9217986
commit c01548d3a0
13 changed files with 822 additions and 536 deletions

View File

@@ -71,13 +71,29 @@ export class Client {
auth(params: {
provider: "mixin" | "github" | "bandu" | "email";
code: string;
code?: string;
deviceCode?: string;
phoneNumber?: string;
email?: string;
mixinId?: string;
}): Promise<UserType> {
return this.api.post("/api/sessions", decamelizeKeys(params));
}
info(): Promise<any> {
return this.api.get("/api/info");
}
deviceCode(provider = "github"): Promise<{
deviceCode: string;
userCode: string;
verificationUri: string;
expiresIn: number;
interval: number;
}> {
return this.api.post("/api/sessions/device_code", { provider });
}
me(): Promise<UserType> {
return this.api.get("/api/me");
}
@@ -93,7 +109,11 @@ export class Client {
return this.api.put(`/api/users/${id}`, decamelizeKeys(params));
}
loginCode(params: { phoneNumber?: string; email?: string }): Promise<void> {
loginCode(params: {
phoneNumber?: string;
email?: string;
mixinId?: string;
}): Promise<void> {
return this.api.post("/api/sessions/login_code", decamelizeKeys(params));
}
@@ -166,7 +186,15 @@ export class Client {
page?: number;
items?: number;
userId?: string;
type?: "all" | "recording" | "medium" | "story" | "prompt" | "text" | "gpt" | "note";
type?:
| "all"
| "recording"
| "medium"
| "story"
| "prompt"
| "text"
| "gpt"
| "note";
by?: "following" | "all";
}): Promise<
{