Skip to content

Commit

Permalink
Remove unecessary async
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Apr 9, 2024
1 parent e11e776 commit 9014007
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/app/auth/resetPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ function ResetPasswordScreen() {
}
}, [hasUppercase, hasLowercase, hasLength, hasNumber, isDifferent]);

const checkPassword = async (text: string) => {
const checkPassword = (text: string) => {
if (text !== '') {
isPasswordSameAsBefore(text, session?.user?.id).then(isSame => setIsDifferent(!isSame))
isPasswordSameAsBefore(text, session?.user?.id).then(isSame =>
setIsDifferent(!isSame),
);
setHasUppercase(text !== text.toLowerCase());
setHasLowercase(text !== text.toUpperCase());
setHasNumber(/[0-9]/.test(text));
Expand Down Expand Up @@ -72,7 +74,7 @@ function ResetPasswordScreen() {
const { error } = await updateUser({ password });

if (error) {
console.error(error)
console.error(error);
Alert.alert('Updating password failed');
} else {
await signOut();
Expand Down
16 changes: 9 additions & 7 deletions src/queries/profiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ export async function isEmailTaken(newEmail: string) {
return emailIsTaken as boolean;
}

export async function isPasswordSameAsBefore(new_plain_password: string, user_id: string | undefined): Promise<boolean> {
let { data, error } = await supabase
.rpc('check_same_as_old_pass', {
new_plain_password,
user_id
})
export async function isPasswordSameAsBefore(
new_plain_password: string,
user_id: string | undefined,
): Promise<boolean> {
let { data, error } = await supabase.rpc('check_same_as_old_pass', {
new_plain_password,
user_id,
});

if (error) {
console.error(error);
return false;
} else {
return data
return data;
}
}

0 comments on commit 9014007

Please sign in to comment.