-
Notifications
You must be signed in to change notification settings - Fork 0
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
added security #6
Conversation
@NotBlank | ||
@Size(min = 6, max = 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NotBlank | |
@Size(min = 6, max = 100) |
@Data | ||
public class UserLoginRequestDto { | ||
@Email(message = "Email is not valid", | ||
regexp = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this regexp?
@SQLDelete(sql = "UPDATE roles SET is_deleted=true WHERE id=?") | ||
@Where(clause = "is_deleted=false") | ||
@Table(name = "roles") | ||
public class Role { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add equals/hashCode
@Query("FROM User u JOIN FETCH u.roles r " | ||
+ "WHERE u.email = :email " | ||
+ "AND u.isDeleted=FALSE " | ||
+ "AND r.isDeleted=FALSE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Query("FROM User u JOIN FETCH u.roles r " | |
+ "WHERE u.email = :email " | |
+ "AND u.isDeleted=FALSE " | |
+ "AND r.isDeleted=FALSE") | |
@EntityGraph(attributePaths = "roles") |
Role adminRole = roleRepository.findRoleByName(Role.RoleName.ADMIN) | ||
.orElseThrow(() -> new RegistrationException("Can't find role by name")); | ||
Set<Role> roles = new HashSet<>(); | ||
if (user.getEmail().startsWith("admin")) { | ||
roles.add(userRole); | ||
roles.add(adminRole); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Role adminRole = roleRepository.findRoleByName(Role.RoleName.ADMIN) | |
.orElseThrow(() -> new RegistrationException("Can't find role by name")); | |
Set<Role> roles = new HashSet<>(); | |
if (user.getEmail().startsWith("admin")) { | |
roles.add(userRole); | |
roles.add(adminRole); | |
} |
Added User entity,
Added Role entity,
Added the required DTOs and mapper,
Added AuthenticationController with the following methods:
Added FieldMatch annotation for checking that password and repeatPassword field in the UserRegistrationRequestDto are the same
RegistrationException and EntityNotFoundException handled using the GlobalExceptionHandler,
Addedthe JWT support to your application