Skip to content

Commit

Permalink
GBS-55 | conversation resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
MenekseYuncu committed Oct 26, 2024
1 parent 223d60a commit 346f64c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class RegisterRequest {

@NotBlank
@Username
@Size(min = 3, max = 20)
private String username;

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void register(RegisterRequest request) {
User user = User.builder()
.firstName(request.getFirstname())
.lastName(request.getLastname())
.username(request.getUsername())
.username(request.getUsername().toLowerCase())
.email(request.getEmail())
.birthDate(request.getBirthDate())
.biography(request.getBiography())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class UsernameValidator implements ConstraintValidator<Username, String> {

private static final String USERNAME_REGEX = "^[a-zA-Z0-9]{3,20}$";
private static final String USERNAME_REGEX = "^[a-zA-Z0-9]$";

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
Expand All @@ -25,7 +25,7 @@ public boolean isValid(String value, ConstraintValidatorContext context) {

if (!lowerCasedValue.matches(USERNAME_REGEX)) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate("Username must be 3-20 characters long and alphanumeric")
context.buildConstraintViolationWithTemplate("Username must be alphanumeric")
.addConstraintViolation();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public class User extends BaseDomainModel {
private Role role;


public String getUsername() {
return username != null ? username.toLowerCase() : null;
}


public boolean isVerified() {
return this.status == UserStatus.VERIFIED;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/db/migration/V1__ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ create table if not exists gb_user
(
id varchar(36) not null primary key,
role_id varchar(36) not null,
email varchar(255) not null,
email varchar(255) not null unique,
password varchar(255) not null,
first_name varchar(25) not null,
last_name varchar(25) not null,
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/db/migration/V2__dml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -277,27 +277,27 @@ values (0, null, 'Bilim', 'Bilim kategorisidir.', 'bilim', 'flask-conical',
insert into gb_user (id, birth_date, email, gender, first_name, last_name, username, password,
status, role_id, created_by, created_at)
values ('22afc9b4-807f-4eb2-b286-788631d1ed55', current_date, '[email protected]',
'FEMALE', 'Test', 'Yönetici', 'yönetici12',
'FEMALE', 'Test', 'Yönetici', ' administrator12',
'$2a$10$atVE.cT5YpEOS7ZLSoVdk.QKVyYBCgvNhvQEuCcXbEMpohYIjbZDG', 'VERIFIED',
'c147b5c2-87f7-4bb7-a165-368f639d8c3c', 'gelecekbilimde', current_timestamp);

insert into gb_user (id, birth_date, email, gender, first_name, last_name, username, password,
status, role_id, created_by, created_at)
values ('99af408c-bec9-4cf2-a5ea-218b12b88a50', current_date, '[email protected]',
'FEMALE', 'Test', 'Moderatör', 'moderatör12',
'FEMALE', 'Test', 'Moderatör', 'moderator12',
'$2a$10$atVE.cT5YpEOS7ZLSoVdk.QKVyYBCgvNhvQEuCcXbEMpohYIjbZDG', 'VERIFIED',
'1ed82a25-d348-4576-b4e6-1f2a7c430ca7', 'gelecekbilimde', current_timestamp);

insert into gb_user (id, birth_date, email, gender, first_name, last_name, username, password,
status, role_id, created_by, created_at)
values ('fee95298-952d-4d1c-81dd-ae5a96b964e5', current_date, '[email protected]',
'MALE', 'Test', 'Yazar', 'yazar12',
'MALE', 'Test', 'Yazar', 'author12',
'$2a$10$atVE.cT5YpEOS7ZLSoVdk.QKVyYBCgvNhvQEuCcXbEMpohYIjbZDG', 'VERIFIED',
'4d98a76c-9841-4aea-b296-2f27aa610b6c', 'gelecekbilimde', current_timestamp);

insert into gb_user (id, birth_date, email, gender, first_name, last_name, username, password,
status, role_id, created_by, created_at)
values ('233d4054-e7b9-43ba-8b26-ca9254df78cd', current_date, '[email protected]',
'MALE', 'Test', 'Kullanıcı', 'kullanıcı12',
'MALE', 'Test', 'Kullanıcı', 'users12',
'$2a$10$atVE.cT5YpEOS7ZLSoVdk.QKVyYBCgvNhvQEuCcXbEMpohYIjbZDG', 'VERIFIED',
'e3a1a32d-fcd7-46f0-bb2b-201df6b2b808', 'gelecekbilimde', current_timestamp);

0 comments on commit 346f64c

Please sign in to comment.