feat: prevent email with plug
This commit is contained in:
parent
795fdd6b3f
commit
641531e8b3
|
|
@ -36,10 +36,13 @@ export class AuthService {
|
|||
addToOrg?: boolean | { orgId: string; role: 'USER' | 'ADMIN'; id: string }
|
||||
) {
|
||||
if (provider === Provider.LOCAL) {
|
||||
if (process.env.DISALLOW_PLUS && body.email.includes('+')) {
|
||||
throw new Error('Email with plus sign is not allowed');
|
||||
}
|
||||
const user = await this._userService.getUserByEmail(body.email);
|
||||
if (body instanceof CreateOrgUserDto) {
|
||||
if (user) {
|
||||
throw new Error('User already exists');
|
||||
throw new Error('Email already exists');
|
||||
}
|
||||
|
||||
if (!(await this.canRegister(provider))) {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ export function RegisterAfter({
|
|||
...data,
|
||||
}),
|
||||
})
|
||||
.then((response) => {
|
||||
.then(async (response) => {
|
||||
setLoading(false);
|
||||
if (response.status === 200) {
|
||||
fireEvents('register');
|
||||
|
|
@ -129,7 +129,7 @@ export function RegisterAfter({
|
|||
});
|
||||
} else {
|
||||
form.setError('email', {
|
||||
message: getHelpfulReasonForRegistrationFailure(response.status),
|
||||
message: await response.text(),
|
||||
});
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue