mirror of https://github.com/buster-so/buster.git
Add logging to login
This commit is contained in:
parent
d9c2d02f64
commit
e11128c798
|
@ -1,5 +1,5 @@
|
|||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "web",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "web",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^9.0.0",
|
||||
|
|
|
@ -50,9 +50,9 @@ export const LoginForm: React.FC<{}> = ({}) => {
|
|||
async ({ email, password }: { email: string; password: string }) => {
|
||||
setLoading('email');
|
||||
try {
|
||||
const res = await signInWithEmailAndPassword({ email, password });
|
||||
if (res?.error) throw res.error;
|
||||
await signInWithEmailAndPassword({ email, password });
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
errorFallback(error);
|
||||
setLoading(null);
|
||||
}
|
||||
|
@ -62,9 +62,9 @@ export const LoginForm: React.FC<{}> = ({}) => {
|
|||
const onSignInWithGoogle = useMemoizedFn(async () => {
|
||||
setLoading('google');
|
||||
try {
|
||||
const res = await signInWithGoogle();
|
||||
if (res?.error) throw res.error;
|
||||
await signInWithGoogle();
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
errorFallback(error);
|
||||
setLoading(null);
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ export const LoginForm: React.FC<{}> = ({}) => {
|
|||
setLoading('github');
|
||||
try {
|
||||
const res = await signInWithGithub();
|
||||
if (res?.error) throw res.error;
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
errorFallback(error);
|
||||
setLoading(null);
|
||||
}
|
||||
|
@ -84,8 +84,7 @@ export const LoginForm: React.FC<{}> = ({}) => {
|
|||
const onSignInWithAzure = useMemoizedFn(async () => {
|
||||
setLoading('azure');
|
||||
try {
|
||||
const res = await signInWithAzure();
|
||||
if (res?.error) throw res.error;
|
||||
await signInWithAzure();
|
||||
} catch (error: any) {
|
||||
errorFallback(error);
|
||||
setLoading(null);
|
||||
|
@ -95,11 +94,10 @@ export const LoginForm: React.FC<{}> = ({}) => {
|
|||
const onSignUp = useMemoizedFn(async (d: { email: string; password: string }) => {
|
||||
setLoading('email');
|
||||
try {
|
||||
const res = await signUp(d);
|
||||
if (res?.error) throw res.error;
|
||||
|
||||
await signUp(d);
|
||||
setSignUpSuccess(true);
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
errorFallback(error);
|
||||
setLoading(null);
|
||||
}
|
||||
|
@ -113,6 +111,7 @@ export const LoginForm: React.FC<{}> = ({}) => {
|
|||
if (signUpFlow) onSignUp(d);
|
||||
else onSignInWithUsernameAndPassword(d);
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const errorMessage = rustErrorHandler(error);
|
||||
if (errorMessage?.message == 'User already registered') {
|
||||
onSignInWithUsernameAndPassword(d);
|
||||
|
|
|
@ -17,7 +17,6 @@ export const signInWithEmailAndPassword = async ({
|
|||
password: string;
|
||||
}) => {
|
||||
'use server';
|
||||
|
||||
const supabase = await createClient();
|
||||
|
||||
const { data, error } = await supabase.auth.signInWithPassword({
|
||||
|
@ -26,7 +25,7 @@ export const signInWithEmailAndPassword = async ({
|
|||
});
|
||||
|
||||
if (error) {
|
||||
return { error: error.message };
|
||||
throw error;
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout');
|
||||
|
@ -50,7 +49,7 @@ export const signInWithGoogle = async () => {
|
|||
});
|
||||
|
||||
if (error) {
|
||||
return { error: error.message };
|
||||
throw error;
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout');
|
||||
|
@ -70,7 +69,7 @@ export const signInWithGithub = async () => {
|
|||
});
|
||||
|
||||
if (error) {
|
||||
return { error: error.message };
|
||||
throw error;
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout');
|
||||
|
@ -91,7 +90,7 @@ export const signInWithAzure = async () => {
|
|||
});
|
||||
|
||||
if (error) {
|
||||
return { error: error.message };
|
||||
throw error;
|
||||
}
|
||||
revalidatePath('/', 'layout');
|
||||
return redirect(data.url);
|
||||
|
@ -99,12 +98,15 @@ export const signInWithAzure = async () => {
|
|||
|
||||
export const signUp = async ({ email, password }: { email: string; password: string }) => {
|
||||
'use server';
|
||||
|
||||
console.log('signUp', email, password);
|
||||
const supabase = await createClient();
|
||||
console.log('supabase', supabase);
|
||||
const authURL = createBusterRoute({
|
||||
route: BusterRoutes.AUTH_CONFIRM
|
||||
});
|
||||
console.log('authURL', authURL);
|
||||
const authURLFull = `${process.env.NEXT_PUBLIC_URL}${authURL}`;
|
||||
console.log('authURLFull', authURLFull);
|
||||
|
||||
const { error } = await supabase.auth.signUp({
|
||||
email,
|
||||
|
@ -113,9 +115,9 @@ export const signUp = async ({ email, password }: { email: string; password: str
|
|||
emailRedirectTo: authURLFull
|
||||
}
|
||||
});
|
||||
|
||||
console.log('error', error);
|
||||
if (error) {
|
||||
return { error: error.message };
|
||||
throw error;
|
||||
}
|
||||
|
||||
revalidatePath('/', 'layout');
|
||||
|
|
Loading…
Reference in New Issue