forked from coaidev/coai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcert.go
31 lines (26 loc) · 775 Bytes
/
cert.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
package auth
import (
"chat/utils"
"github.com/goccy/go-json"
"github.com/spf13/viper"
)
type CertResponse struct {
Status bool `json:"status" required:"true"`
Cert bool `json:"cert"`
Teenager bool `json:"teenager"`
}
func Cert(username string) *CertResponse {
res, err := utils.Post("https://api.deeptrain.net/app/cert", map[string]string{
"Content-Type": "application/json",
}, map[string]interface{}{
"password": viper.GetString("auth.access"),
"user": username,
"hash": utils.Sha2Encrypt(username + viper.GetString("auth.salt")),
})
if err != nil || res == nil || res.(map[string]interface{})["status"] == false {
return nil
}
converter, _ := json.Marshal(res)
resp, _ := utils.Unmarshal[CertResponse](converter)
return &resp
}