improving otp sec
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package zw.qantra.tm.domain.models;
|
package zw.qantra.tm.domain.models;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import zw.qantra.tm.domain.enums.Status;
|
import zw.qantra.tm.domain.enums.Status;
|
||||||
@@ -16,6 +17,7 @@ import zw.qantra.tm.domain.enums.Status;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class Otp extends BaseEntity{
|
public class Otp extends BaseEntity{
|
||||||
private String username;
|
private String username;
|
||||||
|
@JsonIgnore
|
||||||
private String otp;
|
private String otp;
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name = "otp_status")
|
@Column(name = "otp_status")
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import zw.qantra.tm.rest.RestService;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -35,6 +37,11 @@ public class NotificationService {
|
|||||||
@Value("${sms.debug}")
|
@Value("${sms.debug}")
|
||||||
private Boolean smsDebug;
|
private Boolean smsDebug;
|
||||||
|
|
||||||
|
@Value("${wa.api.url}")
|
||||||
|
private String waApiUrl;
|
||||||
|
@Value("${wa.api.key}")
|
||||||
|
private String waApiKey;
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendEmail(String to, String subject, String text) {
|
public void sendEmail(String to, String subject, String text) {
|
||||||
sendEmailWithHtml(to, subject, text, null);
|
sendEmailWithHtml(to, subject, text, null);
|
||||||
@@ -97,6 +104,24 @@ public class NotificationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void sendWA(String chatId, String text) {
|
||||||
|
try {
|
||||||
|
Map<String, String> payload = new HashMap<>();
|
||||||
|
payload.put("chatId", chatId);
|
||||||
|
payload.put("text", text);
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("X-API-Key", waApiKey);
|
||||||
|
|
||||||
|
restService.postWithExternalAuth(waApiUrl, payload, headers, Object.class);
|
||||||
|
|
||||||
|
logger.info("WA message sent to {}: {}", chatId, text);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Failed to send WA message to {}: {}", chatId, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendSms(String to, String message) {
|
public void sendSms(String to, String message) {
|
||||||
if(smsDebug) {
|
if(smsDebug) {
|
||||||
|
|||||||
@@ -90,4 +90,7 @@ sms-pop.url=https://smspop.co.zw/api/campaigns
|
|||||||
sms-pop.apikey=108|ypBpUtJGlPzelxJl2aySp672I9KKbyaQPtcxMPBrfb70be27
|
sms-pop.apikey=108|ypBpUtJGlPzelxJl2aySp672I9KKbyaQPtcxMPBrfb70be27
|
||||||
|
|
||||||
cloudflare-token=cfut_U0qhvhzAATLqHQa9lad7oRmBmPoJ6n9uIoCBbNOWc9884f18
|
cloudflare-token=cfut_U0qhvhzAATLqHQa9lad7oRmBmPoJ6n9uIoCBbNOWc9884f18
|
||||||
cloudflare-zone-id=378cea8e50c0d9a158816109b3b1fd8d
|
cloudflare-zone-id=378cea8e50c0d9a158816109b3b1fd8d
|
||||||
|
|
||||||
|
wa.api.url=http://173.212.247.232:2785/api/sessions/70eae8dc-2be8-465a-a54b-b6c1d3313699/messages/send-text
|
||||||
|
wa.api.key=owa_k1_3d2198d81573303f0b48c3c4a6981fd13261b1d0099758eabf4efb53beaba77d
|
||||||
|
|||||||
Reference in New Issue
Block a user