mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Fix for learn to code anon user path
This commit is contained in:
parent
afdadde568
commit
3ec9a02bc4
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import useWindowWidth from '@/hooks/useWindowWidth';
|
import useWindowWidth from '@/hooks/useWindowWidth';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { signIn, useSession } from 'next-auth/react';
|
import { getSession, signIn, useSession } from 'next-auth/react';
|
||||||
import { useImageProxy } from '@/hooks/useImageProxy';
|
import { useImageProxy } from '@/hooks/useImageProxy';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { Avatar } from 'primereact/avatar';
|
import { Avatar } from 'primereact/avatar';
|
||||||
@ -82,10 +82,26 @@ const HeroBanner = () => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Proceed with anonymous sign in
|
// Proceed with anonymous sign in
|
||||||
signIn('anonymous', {
|
const result = await signIn('anonymous', {
|
||||||
callbackUrl: starterCourseUrl,
|
callbackUrl: starterCourseUrl,
|
||||||
redirect: true,
|
redirect: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (result?.ok) {
|
||||||
|
// Wait a moment for the session to be updated
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
|
||||||
|
// Fetch the session
|
||||||
|
const session = await getSession();
|
||||||
|
|
||||||
|
if (session?.user?.pubkey && session?.user?.privkey) {
|
||||||
|
localStorage.setItem('anonymousPubkey', session.user.pubkey);
|
||||||
|
localStorage.setItem('anonymousPrivkey', session.user.privkey);
|
||||||
|
router.push('/');
|
||||||
|
} else {
|
||||||
|
console.error("Session data incomplete:", session);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user