Skip to content
Merged
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
4 changes: 2 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@aws-sdk/client-s3": "3.1000.0",
"@aws-sdk/s3-request-presigner": "3.1000.0",
"@better-auth/drizzle-adapter": "^1.6.22",
"@better-auth/drizzle-adapter": "^1.7.12",
"@codemirror/lang-yaml": "^6.0.0",
"@codemirror/merge": "^6.0.0",
"@codemirror/state": "^6.0.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"@zxcvbn-ts/core": "^4.1.2",
"ai": "^6.0.116",
"ansi-to-react": "^6.2.6",
"better-auth": "^1.6.22",
"better-auth": "^1.7.12",
"better-sse": "^0.16.1",
"change-case": "^5.4.4",
"class-variance-authority": "^0.7.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 9 additions & 22 deletions apps/web/src/app/(onboarding)/setup/StepAuthEnvVars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ import {

const BOOTSTRAP_SIGN_IN_CALLBACK_PATH = '/setup';

function getOAuth2ProviderId(
// Microsoft sign-in is registered under the Entra provider id.
function toSocialProviderId(
providerId: SetupAuthStatus['preselectedProvider'],
): string | null {
switch (providerId) {
case 'slack':
return providerId;
case 'microsoft':
return 'microsoft-entra-id';
default:
return null;
}
): string {
return providerId === 'microsoft' ? 'microsoft-entra-id' : providerId;
}

export function StepAuthEnvVars({
Expand Down Expand Up @@ -117,18 +111,11 @@ export function StepAuthEnvVars({
selectedProvider.id,
BOOTSTRAP_SIGN_IN_CALLBACK_PATH,
);
const oauth2ProviderId = getOAuth2ProviderId(selectedProvider.id);
const result = oauth2ProviderId
? await authClient.signIn.oauth2({
providerId: oauth2ProviderId,
callbackURL,
disableRedirect: true,
})
: await authClient.signIn.social({
provider: selectedProvider.id,
callbackURL,
disableRedirect: true,
});
const result = await authClient.signIn.social({
provider: toSocialProviderId(selectedProvider.id),
callbackURL,
disableRedirect: true,
});

if (result.error) {
toast.error(result.error.message || 'Unable to sign in.');
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/app/(unauthenticated)/auth-form.client.test.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apps/web/src/app/(unauthenticated)/auth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export function AuthForm({

try {
const callbackURL = getAuthProviderCallbackUrl(provider, redirectUrl);
const result = await authClient.signIn.oauth2({
providerId: provider === 'slack' ? provider : 'microsoft-entra-id',
const result = await authClient.signIn.social({
provider: provider === 'slack' ? provider : 'microsoft-entra-id',
callbackURL,
});

Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/app/api/teams/auth/__tests__/route.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apps/web/src/app/api/teams/auth/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ async function startMicrosoftOAuth({
const authResponse = await handleAuthRequest(
new Request(
new URL(
type === 'link' ? '/api/auth/oauth2/link' : '/api/auth/sign-in/oauth2',
type === 'link' ? '/api/auth/link-social' : '/api/auth/sign-in/social',
callbackHost,
),
{
method: 'POST',
headers,
body: JSON.stringify({
providerId: MICROSOFT_ENTRA_PROVIDER_ID,
provider: MICROSOFT_ENTRA_PROVIDER_ID,
callbackURL: returnPath,
errorCallbackURL: returnPath,
}),
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/hooks/linked-accounts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function createUseAuthenticateOAuthLinkedAccount({
return function useAuthenticateOAuthLinkedAccount() {
return useMutation({
mutationFn: async (redirectPath: string) => {
const result = await authClient.oauth2.link({
providerId,
const result = await authClient.linkSocial({
provider: providerId,
callbackURL: redirectPath,
errorCallbackURL: redirectPath,
});
Expand Down
27 changes: 27 additions & 0 deletions apps/web/src/lib/auth-client.client.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions apps/web/src/lib/auth-client.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use client';

import { createAuthClient } from 'better-auth/react';
import { genericOAuthClient } from 'better-auth/client/plugins';

type BaseAuthClient = ReturnType<typeof createAuthClient>;
type OAuth2SignInInput = {
callbackURL?: string;
disableRedirect?: boolean;
providerId: string;
provider: string;
};
type OAuth2SignInResult = {
data?: { redirect?: boolean; url?: string } | null;
Expand All @@ -16,7 +15,7 @@ type OAuth2SignInResult = {
type OAuth2LinkInput = {
callbackURL: string;
errorCallbackURL?: string;
providerId: string;
provider: string;
scopes?: string[];
};
type OAuth2LinkResult = {
Expand Down Expand Up @@ -58,17 +57,14 @@ type ChangeEmailResult = {
};
type RoomoteAuthClient = BaseAuthClient & {
signIn: BaseAuthClient['signIn'] & {
oauth2(input: OAuth2SignInInput): Promise<OAuth2SignInResult>;
};
oauth2: {
link(input: OAuth2LinkInput): Promise<OAuth2LinkResult>;
social(input: OAuth2SignInInput): Promise<OAuth2SignInResult>;
};
linkSocial(input: OAuth2LinkInput): Promise<OAuth2LinkResult>;
unlinkAccount(input: UnlinkAccountInput): Promise<UnlinkAccountResult>;
resetPassword(input: ResetPasswordInput): Promise<ResetPasswordResult>;
changePassword(input: ChangePasswordInput): Promise<ChangePasswordResult>;
changeEmail(input: ChangeEmailInput): Promise<ChangeEmailResult>;
};

export const authClient: RoomoteAuthClient = createAuthClient({
plugins: [genericOAuthClient()],
}) as RoomoteAuthClient;
export const authClient: RoomoteAuthClient =
createAuthClient() as RoomoteAuthClient;
Loading
Loading