@@ -2,7 +2,6 @@ package rpc
2
2
3
3
import (
4
4
"encoding/hex"
5
- "encoding/json"
6
5
"io/ioutil"
7
6
"log"
8
7
"math"
@@ -39,7 +38,6 @@ var UserRPC = map[int][]string{
39
38
11 : []string {"/user/trustasset" , "GET" , "assetCode" , "assetIssuer" , "limit" , "seedpwd" }, // GET
40
39
12 : []string {"/upload" , "POST" }, // POST
41
40
13 : []string {"/platformemail" , "GET" }, // GET
42
- 16 : []string {"/tellerping" , "GET" }, // GET
43
41
17 : []string {"/user/increasetrustlimit" , "GET" , "trust" , "seedpwd" }, // GET
44
42
19 : []string {"/user/sendrecovery" , "GET" , "email1" , "email2" , "email3" }, // GET
45
43
20 : []string {"/user/seedrecovery" , "GET" , "secret1" , "secret2" }, // GET
@@ -60,11 +58,13 @@ var UserRPC = map[int][]string{
60
58
36 : []string {"/user/progress" , "POST" , "progress" }, // POST
61
59
37 : []string {"/user/update" , "POST" }, // POST
62
60
38 : []string {"/user/tellerfile" , "GET" }, // GET
61
+ 39 : []string {"/user/logout" , "POST" }, // POST
63
62
64
63
30 : []string {"/user/anchorusd/kyc" , "GET" , "name" , "bdaymonth" , "bdayday" , "bdayyear" , "taxcountry" , // GET
65
64
"taxid" , "addrstreet" , "addrcity" , "addrpostal" , "addrregion" , "addrcountry" , "addrphone" , "primaryphone" , "gender" },
66
65
// 14: []string{"/tellershutdown", "projIndex", "deviceId", "tx1", "tx2"},
67
66
// 15: []string{"/tellerpayback", "deviceId", "projIndex"},
67
+ // 16: []string{"/tellerping", "GET", "index"},
68
68
// 18: []string{"/utils/addhash", "projIndex", "choice", "choicestr"},
69
69
}
70
70
@@ -84,11 +84,7 @@ func setupUserRpcs() {
84
84
trustAsset ()
85
85
uploadFile ()
86
86
platformEmail ()
87
- // sendTellerShutdownEmail()
88
- // sendTellerFailedPaybackEmail()
89
- tellerPing ()
90
87
increaseTrustLimit ()
91
- // addContractHash()
92
88
sendSecrets ()
93
89
mergeSecrets ()
94
90
generateNewSecrets ()
@@ -109,6 +105,12 @@ func setupUserRpcs() {
109
105
updateProgress ()
110
106
updateUser ()
111
107
downloadTeller ()
108
+ logout ()
109
+
110
+ // sendTellerShutdownEmail()
111
+ // sendTellerFailedPaybackEmail()
112
+ // tellerPing()
113
+ // addContractHash()
112
114
}
113
115
114
116
const (
@@ -611,32 +613,6 @@ func platformEmail() {
611
613
})
612
614
}
613
615
614
- // tellerPing pings the teller to check if its up
615
- func tellerPing () {
616
- http .HandleFunc (UserRPC [16 ][0 ], func (w http.ResponseWriter , r * http.Request ) {
617
- _ , err := userValidateHelper (w , r , UserRPC [16 ][2 :], UserRPC [16 ][1 ])
618
- if err != nil {
619
- return
620
- }
621
-
622
- data , err := erpc .GetRequest (TellerUrl + "/ping" )
623
- if err != nil {
624
- erpc .ResponseHandler (w , erpc .StatusInternalServerError )
625
- return
626
- }
627
-
628
- var x erpc.StatusResponse
629
-
630
- err = json .Unmarshal (data , & x )
631
- if err != nil {
632
- erpc .ResponseHandler (w , erpc .StatusInternalServerError )
633
- return
634
- }
635
-
636
- erpc .MarshalSend (w , x )
637
- })
638
- }
639
-
640
616
// increaseTrustLimit increases the trust limit a user has towards a specific asset on stellar
641
617
func increaseTrustLimit () {
642
618
http .HandleFunc (UserRPC [17 ][0 ], func (w http.ResponseWriter , r * http.Request ) {
@@ -1415,3 +1391,23 @@ func downloadTeller() {
1415
1391
http .ServeFile (w , r , "screenlog.0" )
1416
1392
})
1417
1393
}
1394
+
1395
+ // logout logs out from all devices
1396
+ func logout () {
1397
+ http .HandleFunc (UserRPC [39 ][0 ], func (w http.ResponseWriter , r * http.Request ) {
1398
+ //_, err := userValidateHelper(w, r, UserRPC[38][2:], UserRPC[38][1])
1399
+ user , err := userValidateHelper (w , r , UserRPC [39 ][2 :], UserRPC [39 ][1 ])
1400
+ if err != nil {
1401
+ return
1402
+ }
1403
+
1404
+ err = user .AllLogout () // generate a new token to invalidate the old one
1405
+ if err != nil {
1406
+ log .Println (err )
1407
+ erpc .ResponseHandler (w , erpc .StatusInternalServerError )
1408
+ return
1409
+ }
1410
+
1411
+ erpc .ResponseHandler (w , erpc .StatusOK )
1412
+ })
1413
+ }
0 commit comments