Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage #8147

Merged
merged 6 commits into from
Sep 3, 2024
Merged

Stage #8147

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug: [SUPER ADMIN] Profile - accepts an invalid email address upon save
  • Loading branch information
samuelmbabhazi committed Sep 3, 2024
commit 0497eea46daee269b7ae482b4cbe8b242a5dd986
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const patterns = {
websiteUrl: /^((?:https?:\/\/)[^./]+(?:\.[^./]+)+(?:\/.*)?)$/,
imageUrl: /^(http)?s?:?(\/\/[^"']*\.(?:png|jpg|jpeg|gif|png|svg))/,
email: /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(([^<>()[\]\.,;:\s@"]+\.)+[^<>()[\]\.,;:\s@"]{2,})$/i,
host: /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/,
passwordNoSpaceEdges: /^(?!\s).*[^\s]$/
};
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { IUser, ITag, IRole, IUserUpdateInput, RolesEnum, IImageAsset, DEFAULT_T
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Subject, firstValueFrom } from 'rxjs';
import { debounceTime, filter, tap } from 'rxjs/operators';
import { Store } from '@gauzy/ui-core/core';
import { EmailValidator, Store } from '@gauzy/ui-core/core';
import {
AuthService,
ErrorHandlingService,
@@ -14,6 +14,7 @@ import {
UsersService
} from '@gauzy/ui-core/core';
import { FormHelpers } from '../../forms/helpers';
import { patterns } from '../../regex';

@UntilDestroy({ checkProperties: true })
@Component({
@@ -62,7 +63,7 @@ export class EditProfileFormComponent implements OnInit, OnDestroy {
{
firstName: [],
lastName: [],
email: [null, Validators.required],
email: [null, [Validators.required, Validators.email]],
imageUrl: [{ value: null, disabled: true }],
imageId: [],
password: [],
@@ -183,6 +184,10 @@ export class EditProfileFormComponent implements OnInit, OnDestroy {
const { timeFormat, timeZone } = this.form.value;
const { email, firstName, lastName, tags, preferredLanguage, password, phoneNumber } = this.form.value;

if (!EmailValidator.isValid(email, patterns.email)) {
this.toastrService.error('TOASTR.MESSAGE.EMAIL_SHOULD_BE_REAL');
return;
}
let request: IUserUpdateInput = {
email,
firstName,
Loading