feat(auth): added discord & github authentication methods (#18)
* feat(auth): added discord & github authentication methods * chore(format): formatted edited files * docs: add Discord and GitHub OAuth environment variables to README * feat: add Discord and GitHub OAuth client credentials to environment config * refactor: migrate social provider types to better-auth package * feat: return configured social provider names from auth endpoint * refactor: simplify socialProvidersPlugin by removing nested function and condensing return
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
import { BetterAuthClientPlugin } from "better-auth";
|
||||
import { apiKeyClient, magicLinkClient } from "better-auth/client/plugins";
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
import { BetterFetchOption, createAuthClient } from "better-auth/react";
|
||||
|
||||
import { socialProvidersPlugin } from "./auth";
|
||||
|
||||
const socialProvidersPluginClient = {
|
||||
id: "social-providers-plugin",
|
||||
$InferServerPlugin: {} as ReturnType<typeof socialProvidersPlugin>,
|
||||
getActions: ($fetch) => {
|
||||
return {
|
||||
getSocialProviders: async (fetchOptions?: BetterFetchOption) => {
|
||||
const res = $fetch("/social-providers", {
|
||||
method: "GET",
|
||||
...fetchOptions,
|
||||
});
|
||||
return res.then((res) => res.data as string[]);
|
||||
},
|
||||
};
|
||||
},
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
plugins: [magicLinkClient(), apiKeyClient()],
|
||||
plugins: [magicLinkClient(), apiKeyClient(), socialProvidersPluginClient],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user