Skip to content

Commit

Permalink
Merge pull request #72 from ADORSYS-GIS/feat/prevent-duplicate-accounts
Browse files Browse the repository at this point in the history
Feat/prevent duplicate accounts
  • Loading branch information
Arielpetit authored Feb 25, 2025
2 parents c319458 + 1716194 commit 791cd74
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 57 deletions.
5 changes: 0 additions & 5 deletions prs/prs-rest-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@ jwt.issuer=${JWT_ISSUER}
jwt.expiration-time-ms=${JWT_EXPIRATION_TIME_MS}

server.forward-headers-strategy=framework

spring.redis.host=${SPRING_REDIS_HOST:localhost}
spring.redis.port=${SPRING_REDIS_PORT:6379}
spring.redis.password=${SPRING_REDIS_PASSWORD:your_password}
spring.redis.timeout=${SPRING_REDIS_TIMEOUT:2000}
11 changes: 1 addition & 10 deletions prs/prs-service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,7 @@
<artifactId>java-json-canonicalization</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>3.4.2</version>
</dependency>


</dependencies>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
import com.nimbusds.jose.jwk.ECKey;
import com.nimbusds.jose.jwk.JWK;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import jakarta.annotation.PostConstruct;
import org.erdtman.jcs.JsonCanonicalizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -51,7 +48,6 @@ public class OtpServiceImpl implements OtpServiceApi {
private String SERVER_PUBLIC_KEY_JSON;

@Autowired
private RedisTemplate<String, String> redisTemplate;

@PostConstruct
public void initTwilio() {
Expand All @@ -72,9 +68,6 @@ public String sendOtp(JWK devicePub, String phoneNumber) {
}

try {
// Check if the phone number exists in Redis cache
if (phoneNumber.length() != 11) {
log.info("Phone number {} not found in cache.", phoneNumber);

String otp = generateOtp();
log.info("OTP sent to phone number:{}", otp);
Expand All @@ -91,20 +84,16 @@ public String sendOtp(JWK devicePub, String phoneNumber) {
String otpHash = computeHash(input);
log.info("OTP hash:{}", otpHash);

// Send OTP via Twilio (if desired, uncomment this part)
// Message message = Message.creator(
// new PhoneNumber(phoneNumber),
// new PhoneNumber(fromPhoneNumber),
// "Your OTP is: " + otp
// ).create();
// Send OTP via Twilio (if desired, uncomment this part)
// Message message = Message.creator(
// new PhoneNumber(phoneNumber),
// new PhoneNumber(fromPhoneNumber),
// "Your OTP is: " + otp
// ).create();

log.info("Message sent to phone number: {}", phoneNumber);

return otpHash;
} else {
log.warn("Phone number {} exists in the cache.", phoneNumber);
return "Phone number {} exists in the cache.";
}

} catch (Exception e) {
throw new FailedToSendOTPException("Failed to send OTP");
Expand Down

0 comments on commit 791cd74

Please sign in to comment.