Just making a mess mostly I think
This commit is contained in:
@ -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 (
|
||||
|
Reference in New Issue
Block a user