Just making a mess mostly I think

This commit is contained in:
2025-06-14 15:58:18 -05:00
parent 0e62bafa45
commit d78c139ffb
14 changed files with 292 additions and 306 deletions

View File

@ -3,8 +3,7 @@
import 'server-only';
import { createServerClient } from '@/utils/supabase';
import { headers } from 'next/headers';
import type { User } from '@/utils/supabase';
import type { Result } from '.';
import type { User, Result } from '@/utils/supabase';
export const signUp = async (
formData: FormData,
@ -58,31 +57,37 @@ export const signIn = async (formData: FormData): Promise<Result<null>> => {
}
};
export const signInWithMicrosoft = async (): Promise<Result<string>> => {
type OAuthReturn = {
provider: string;
url: string;
};
export const signInWithMicrosoft = async (): Promise<Result<OAuthReturn>> => {
const supabase = await createServerClient();
const origin = (await headers()).get('origin');
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'azure',
options: {
scopes: 'openid, profile email offline_access',
scopes: 'openid profile email offline_access',
redirectTo: `${origin}/auth/callback?redirect_to=/auth/success`,
},
});
if (error) return { success: false, error: error.message };
return { success: true, data: data.url };
return { success: true, data };
};
export const signInWithApple = async (): Promise<Result<string>> => {
export const signInWithApple = async (): Promise<Result<OAuthReturn>> => {
const supabase = await createServerClient();
const origin = process.env.BASE_URL!;
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'apple',
options: {
scopes: 'openid profile email offline_access',
redirectTo: `${origin}/auth/callback?redirect_to=/auth/success`,
},
});
if (error) return { success: false, error: error.message };
return { success: true, data: data.url };
return { success: true, data };
};
export const forgotPassword = async (