-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotp.go
39 lines (30 loc) · 834 Bytes
/
otp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"encoding/json"
"net/http"
"strings"
)
// SendOTP .
func SendOTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
var response = make(map[string]interface{})
response["status"] = "200"
response["message"] = "OTP sent"
response["message_type"] = "1"
json.NewEncoder(w).Encode(response)
}
// VerifyOTP .
func VerifyOTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
var response = make(map[string]interface{})
if strings.EqualFold(r.FormValue("otp"), "4242") {
response["status"] = "200"
response["message"] = ""
response["message_type"] = ""
} else {
response["status"] = "400"
response["message"] = "Incorrect OTP"
response["message_type"] = "1"
}
json.NewEncoder(w).Encode(response)
}