Not even sure but I'm sure it's better
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
import 'server-only';
|
||||
import { encodedRedirect } from '@/utils/utils';
|
||||
import { createServerClient } from '@/utils/supabase';
|
||||
import type { User } from '@supabase/supabase-js'
|
||||
import type { User } from '@supabase/supabase-js';
|
||||
import { headers } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import type { Result } from './index';
|
||||
@ -119,11 +119,7 @@ export const resetPassword = async (formData: FormData) => {
|
||||
}
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
encodedRedirect(
|
||||
'error',
|
||||
'/reset-password',
|
||||
'Passwords do not match',
|
||||
);
|
||||
encodedRedirect('error', '/reset-password', 'Passwords do not match');
|
||||
}
|
||||
|
||||
const { error } = await supabase.auth.updateUser({
|
||||
@ -131,11 +127,7 @@ export const resetPassword = async (formData: FormData) => {
|
||||
});
|
||||
|
||||
if (error) {
|
||||
encodedRedirect(
|
||||
'error',
|
||||
'/reset-password',
|
||||
'Password update failed',
|
||||
);
|
||||
encodedRedirect('error', '/reset-password', 'Password update failed');
|
||||
}
|
||||
|
||||
encodedRedirect('success', '/reset-password', 'Password updated');
|
||||
@ -152,8 +144,8 @@ export const getUser = async (): Promise<Result<User>> => {
|
||||
const supabase = await createServerClient();
|
||||
const { data, error } = await supabase.auth.getUser();
|
||||
if (error) throw error;
|
||||
return {success: true, data: data.user};
|
||||
return { success: true, data: data.user };
|
||||
} catch (error) {
|
||||
return {success: false, error: 'Could not get user!'};
|
||||
return { success: false, error: 'Could not get user!' };
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user