feat: allow platforms to define additional entries in the login dialog

This commit is contained in:
Andrew Bastin
2023-08-14 21:11:25 +05:30
parent 2d104160f2
commit 71bcd22444
2 changed files with 31 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
import { ClientOptions } from "@urql/core"
import { Observable } from "rxjs"
import { Component } from "vue"
import { getI18n } from "~/modules/i18n"
/**
* A common (and required) set of fields that describe a user.
@@ -39,6 +41,13 @@ export type GithubSignInResult =
| { type: "account-exists-with-different-cred"; link: () => Promise<void> } // We authenticated correctly, but the provider didn't match, so we give the user the opportunity to link to continue completing auth
| { type: "error"; err: unknown } // Auth failed completely and we don't know why
export type LoginItemDef = {
id: string
icon: Component
text: (t: ReturnType<typeof getI18n>) => string
onClick: () => Promise<void> | void
}
export type AuthPlatformDef = {
/**
* Returns an observable that emits the current user as per the auth implementation.
@@ -212,4 +221,9 @@ export type AuthPlatformDef = {
* @returns An empty promise that is resolved when the operation is complete
*/
setDisplayName: (name: string) => Promise<void>
/**
* Defines the additional login items that should be shown in the login screen
*/
additionalLoginItems?: LoginItemDef[]
}