Skip to content

Commit

Permalink
remove auth api and fix logging in update endorsement api
Browse files Browse the repository at this point in the history
  • Loading branch information
yesyash committed Jul 28, 2024
1 parent 077f4a8 commit cd0122f
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 116 deletions.
31 changes: 0 additions & 31 deletions skill-tree/src/main/java/com/RDS/skilltree/apis/AuthApi.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public EndorsementViewModel update(Integer endorsementId, UpdateEndorsementViewM
Optional<Endorsement> exitingEndorsement = endorsementRepository.findById(endorsementId);

if (exitingEndorsement.isEmpty()) {
throw new EndorsementNotFoundException(
String.format("Endorsement with id: %s not found", endorsementId));
log.error(String.format("Endorsement with id: %s not found", endorsementId));
throw new EndorsementNotFoundException("Endorsement not found");
}

Endorsement endorsement = exitingEndorsement.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

public interface RdsService {
RdsGetUserDetailsResDto getUserDetails(String id);

String signIn(String callbackUrl);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.RDS.skilltree.services.external;

import com.RDS.skilltree.dtos.RdsGetUserDetailsResDto;
import com.RDS.skilltree.exceptions.InternalServerErrorException;
import com.RDS.skilltree.exceptions.UserNotFoundException;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

@Service
@RequiredArgsConstructor
Expand All @@ -33,28 +29,4 @@ public RdsGetUserDetailsResDto getUserDetails(String id) {
throw new UserNotFoundException("Error getting user details");
}
}

@Override
public String signIn(String callbackUrl) {
String url =
UriComponentsBuilder.fromUriString(rdsBackendBaseUrl)
.path("/auth/github/login")
.queryParam("redirectURL", callbackUrl)
.queryParam("v2", true)
.toUriString();

try {
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);

if (response.getStatusCode().is5xxServerError()
|| response.getStatusCode().is4xxClientError()) {
throw new InternalServerErrorException("Something went wrong during authentication");
}

return response.getHeaders().getFirst(HttpHeaders.LOCATION);
} catch (RestClientException error) {
log.error("Error calling url: {}, Error : {}", url, error.getMessage());
throw new RuntimeException("Failed to communicate with RDS backend");
}
}
}

0 comments on commit cd0122f

Please sign in to comment.