Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Deploy to GKE
run: |
kubectl set image deployment/security-service \
security-service=docker.io/dockerforomar/micropay-security:latest
security-service=docker.io/dockerforomar/micropay-security:${{ github.sha }}
kubectl rollout status deployment/security-service


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.micropay.security.exception.handler;

import com.micropay.security.exception.DuplicateObjectException;
import com.micropay.security.exception.InvalidTokenException;
import com.micropay.security.exception.NotActiveUserException;
import com.micropay.security.exception.UserNotFoundException;
import com.micropay.security.exception.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import com.micropay.security.dto.response.ErrorResponse;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
Expand Down Expand Up @@ -78,4 +76,14 @@ public ResponseEntity<ErrorResponse> handleInvalidTokenException(InvalidTokenExc
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(body);
}

@ExceptionHandler(BadCredentialsException.class)
public ResponseEntity<ErrorResponse> handleBadCredentialsException(BadCredentialsException exception) {
ErrorResponse body = new ErrorResponse(
HttpStatus.UNAUTHORIZED.value(),
exception.getMessage(),
LocalDateTime.now()
);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(body);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public String hashPin(String pin) {
@Override
public void checkPinMatching(String rawPin, String hashedPin) {
if (!passwordEncoder.matches(rawPin, hashedPin)) {
throw new BadCredentialsException("Passwords do not match.");
throw new BadCredentialsException("Invalid PIN.");
}
}

Expand Down
Loading