-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcfHandler.go
38 lines (34 loc) · 990 Bytes
/
gcfHandler.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
package email
import (
"encoding/json"
"net/http"
intermoni "github.com/intern-monitoring/backend-intermoni"
)
var (
Response intermoni.Response
user intermoni.User
)
func Put(PASETOPUBLICKEYENV, MONGOCONNSTRINGENV, dbname string, r *http.Request) string {
conn := intermoni.MongoConnect(MONGOCONNSTRINGENV, dbname)
Response.Status = false
//
user_login, err := intermoni.GetUserLogin(PASETOPUBLICKEYENV, r)
if err != nil {
Response.Message = "Gagal Decode Token : " + err.Error()
return intermoni.GCFReturnStruct(Response)
}
err = json.NewDecoder(r.Body).Decode(&user)
if err != nil {
Response.Message = "error parsing application/json: " + err.Error()
return intermoni.GCFReturnStruct(Response)
}
err = UpdateEmailUser(user_login.Id, conn, user)
if err != nil {
Response.Message = err.Error()
return intermoni.GCFReturnStruct(Response)
}
//
Response.Status = true
Response.Message = "Berhasil Update Email"
return intermoni.GCFReturnStruct(Response)
}