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

@ -7,6 +7,7 @@ import Image from 'next/image';
import { type buttonVariants } from '@/components/ui';
import { type ComponentProps } from 'react';
import { type VariantProps } from 'class-variance-authority';
import { getProfile, updateProfile } from '@/lib/hooks';
type SignInWithMicrosoftProps = {
className?: ComponentProps<'div'>['className'];
@ -32,8 +33,22 @@ export const SignInWithMicrosoft = ({
const result = await signInWithMicrosoft();
if (result?.success && result.data) {
// Redirect to Microsoft OAuth page
window.location.href = result.data;
const profileResponse = await getProfile();
if (profileResponse.success) {
const profile = profileResponse.data;
if (!profile.provider) {
const updateResponse = await updateProfile({
provider: result.data.provider,
})
if (!updateResponse.success) throw new Error('Could not update provider!');
} else {
const updateResponse = await updateProfile({
provider: profile.provider + ' ' + result.data.provider,
})
if (!updateResponse.success) throw new Error('Could not update provider!');
}
}
window.location.href = result.data.url;
} else {
setStatusMessage(`Error: Could not sign in with Microsoft!`);
}