improving otp sec
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package zw.qantra.tm.domain.models;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import zw.qantra.tm.domain.enums.Status;
|
||||
@@ -16,6 +17,7 @@ import zw.qantra.tm.domain.enums.Status;
|
||||
@NoArgsConstructor
|
||||
public class Otp extends BaseEntity{
|
||||
private String username;
|
||||
@JsonIgnore
|
||||
private String otp;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "otp_status")
|
||||
|
||||
@@ -18,6 +18,8 @@ import zw.qantra.tm.rest.RestService;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -35,6 +37,11 @@ public class NotificationService {
|
||||
@Value("${sms.debug}")
|
||||
private Boolean smsDebug;
|
||||
|
||||
@Value("${wa.api.url}")
|
||||
private String waApiUrl;
|
||||
@Value("${wa.api.key}")
|
||||
private String waApiKey;
|
||||
|
||||
@Async
|
||||
public void sendEmail(String to, String subject, String text) {
|
||||
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
|
||||
public void sendSms(String to, String message) {
|
||||
if(smsDebug) {
|
||||
|
||||
@@ -90,4 +90,7 @@ sms-pop.url=https://smspop.co.zw/api/campaigns
|
||||
sms-pop.apikey=108|ypBpUtJGlPzelxJl2aySp672I9KKbyaQPtcxMPBrfb70be27
|
||||
|
||||
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