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

Basic auth #9

Merged
merged 6 commits into from
Sep 17, 2024
Merged

Basic auth #9

merged 6 commits into from
Sep 17, 2024

Conversation

ChabVlad
Copy link
Owner

No description provided.

Copy link

@Elena-Bruyako Elena-Bruyako left a 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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package project.bookstore.annotation;
package project.bookstore.validation;


Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

import org.springframework.beans.BeanWrapperImpl;

public class FieldMatchValidator implements ConstraintValidator<FieldMatch, Object> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 26 to 34
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


@Override
public UserResponseDto register(UserRegistrationRequestDto requestDto) {
if (userRepository.findByEmail(requestDto.getEmail()) != null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (userRepository.findByEmail(requestDto.getEmail()) != null) {
if (userRepo.existsByEmail(requestDto.getEmail())) {

@ChabVlad ChabVlad merged commit cd97bf2 into main Sep 17, 2024
2 checks passed
@ChabVlad ChabVlad deleted the basic_auth branch September 17, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants