-
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
Basic auth #9
Basic auth #9
Conversation
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.
see comments
@@ -0,0 +1,21 @@ | |||
package project.bookstore.annotation; |
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.
package project.bookstore.annotation; | |
package project.bookstore.validation; |
|
||
Class<?>[] groups() default {}; | ||
Class<? extends Payload>[] payload() default {}; | ||
|
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.
import org.springframework.beans.BeanWrapperImpl; | ||
|
||
public class FieldMatchValidator implements ConstraintValidator<FieldMatch, Object> { | ||
|
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.
BeanWrapper beanWrapper = new BeanWrapperImpl(object); | ||
Object firstObject = beanWrapper.getPropertyValue(firstFieldName); | ||
Object secondObject = beanWrapper.getPropertyValue(secondFieldName); | ||
|
||
if (firstObject == null || secondObject == null) { | ||
return false; | ||
} | ||
|
||
return firstObject.equals(secondObject); |
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.
BeanWrapper beanWrapper = new BeanWrapperImpl(object); | |
Object firstObject = beanWrapper.getPropertyValue(firstFieldName); | |
Object secondObject = beanWrapper.getPropertyValue(secondFieldName); | |
if (firstObject == null || secondObject == null) { | |
return false; | |
} | |
return firstObject.equals(secondObject); | |
Object field = new BeanWrapperImpl(value).getPropertyValue(this.firstFieldName); | |
Object fieldMatch = new BeanWrapperImpl(value).getPropertyValue(this.secondFieldName); | |
return Objects.equals(field, fieldMatch); |
message = " The password fields must match" | ||
) | ||
public class UserRegistrationRequestDto { | ||
|
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.
|
||
@Override | ||
public UserResponseDto register(UserRegistrationRequestDto requestDto) { | ||
if (userRepository.findByEmail(requestDto.getEmail()) != null) { |
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.
if (userRepository.findByEmail(requestDto.getEmail()) != null) { | |
if (userRepo.existsByEmail(requestDto.getEmail())) { |
No description provided.