Finally have all email verification / password reset auth flows working!
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { ConvexError } from 'convex/values';
|
||||
import { Password as DefaultPassword } from '@convex-dev/auth/providers/Password';
|
||||
import { validatePassword } from '../password/validate';
|
||||
import type { DataModel } from '../../../_generated/dataModel';
|
||||
import { UsesendOTPPasswordReset } from '../password/reset';
|
||||
import { DataModel } from '../../../_generated/dataModel';
|
||||
import { UseSendOTP, UseSendOTPPasswordReset } from '..';
|
||||
import { ConvexError } from 'convex/values';
|
||||
|
||||
export const Password = DefaultPassword<DataModel>({
|
||||
profile(params, ctx) {
|
||||
@@ -16,5 +15,19 @@ export const Password = DefaultPassword<DataModel>({
|
||||
throw new ConvexError('Invalid password.');
|
||||
}
|
||||
},
|
||||
reset: UsesendOTPPasswordReset,
|
||||
reset: UseSendOTPPasswordReset,
|
||||
verify: UseSendOTP,
|
||||
});
|
||||
|
||||
export const validatePassword = (password: string): boolean => {
|
||||
if (
|
||||
password.length < 8 ||
|
||||
password.length > 100 ||
|
||||
!/\d/.test(password) ||
|
||||
!/[a-z]/.test(password) ||
|
||||
!/[A-Z]/.test(password)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
Reference in New Issue
Block a user