Fix sign in redirect
This commit is contained in:
parent
c98e262fd0
commit
c550534d6c
4 changed files with 20 additions and 4 deletions
|
|
@ -90,7 +90,10 @@ export const AuthButton: React.FC<AuthButtonProps> = ({ onAccountSettingsClick }
|
|||
|
||||
return (
|
||||
<button
|
||||
onClick={() => auth.signinRedirect()}
|
||||
onClick={() => {
|
||||
sessionStorage.setItem('kaboot_auth_return_url', window.location.pathname + window.location.search);
|
||||
auth.signinRedirect();
|
||||
}}
|
||||
className="flex items-center gap-2 bg-white/10 px-4 py-2 rounded-xl hover:bg-white/20 transition font-bold"
|
||||
>
|
||||
<LogIn size={20} />
|
||||
|
|
|
|||
|
|
@ -348,7 +348,10 @@ export const Landing: React.FC<LandingProps> = ({ onGenerate, onCreateManual, on
|
|||
<Lock size={32} className="mx-auto mb-3 text-gray-400" />
|
||||
<p className="text-gray-500 font-bold mb-4">Sign in to host quizzes</p>
|
||||
<button
|
||||
onClick={() => auth.signinRedirect()}
|
||||
onClick={() => {
|
||||
sessionStorage.setItem('kaboot_auth_return_url', window.location.pathname + window.location.search);
|
||||
auth.signinRedirect();
|
||||
}}
|
||||
className="bg-theme-primary text-white py-3 px-6 rounded-2xl font-black hover:opacity-90 transition-all"
|
||||
>
|
||||
Sign In
|
||||
|
|
|
|||
|
|
@ -190,7 +190,10 @@ export const SharedQuizView: React.FC<SharedQuizViewProps> = ({ onHostQuiz, shar
|
|||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => auth.signinRedirect()}
|
||||
onClick={() => {
|
||||
sessionStorage.setItem('kaboot_auth_return_url', window.location.pathname);
|
||||
auth.signinRedirect();
|
||||
}}
|
||||
className="w-full bg-gray-100 text-gray-600 py-3 rounded-2xl text-lg font-black hover:bg-gray-200 shadow-[0_4px_0_#d1d5db] active:shadow-none active:translate-y-[4px] transition-all flex items-center justify-center gap-2"
|
||||
>
|
||||
<LogIn size={20} /> Sign in to Save
|
||||
|
|
|
|||
|
|
@ -34,7 +34,14 @@ if (!rootElement) {
|
|||
const shouldSkipSigninCallback = !window.location.pathname.startsWith('/callback');
|
||||
|
||||
const onSigninCallback = () => {
|
||||
window.history.replaceState({}, document.title, '/');
|
||||
const returnUrl = sessionStorage.getItem('kaboot_auth_return_url');
|
||||
sessionStorage.removeItem('kaboot_auth_return_url');
|
||||
|
||||
if (returnUrl && returnUrl !== '/') {
|
||||
window.location.replace(returnUrl);
|
||||
} else {
|
||||
window.history.replaceState({}, document.title, '/');
|
||||
}
|
||||
};
|
||||
|
||||
const root = ReactDOM.createRoot(rootElement);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue