handler.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. package main
  2. import (
  3. "crypto/sha256"
  4. "crypto/tls"
  5. "encoding/json"
  6. "fmt"
  7. "io/ioutil"
  8. "net/http"
  9. "net/url"
  10. "strings"
  11. "time"
  12. "github.com/dgrijalva/jwt-go"
  13. "github.com/labstack/echo"
  14. )
  15. type handler struct{}
  16. type userInfo struct {
  17. Result struct {
  18. Result struct {
  19. Sshpubkeyfp []string `json:"sshpubkeyfp"`
  20. HasKeytab bool `json:"has_keytab"`
  21. Ipasshpubkey []string `json:"ipasshpubkey"`
  22. Cn []string `json:"cn"`
  23. Krbcanonicalname []string `json:"krbcanonicalname"`
  24. Krbticketflags []string `json:"krbticketflags"`
  25. MemberofGroup []string `json:"memberof_group"`
  26. HasPassword bool `json:"has_password"`
  27. Homedirectory []string `json:"homedirectory"`
  28. Nsaccountlock bool `json:"nsaccountlock"`
  29. UID []string `json:"uid"`
  30. Title []string `json:"title"`
  31. Loginshell []string `json:"loginshell"`
  32. Uidnumber []string `json:"uidnumber"`
  33. Preserved bool `json:"preserved"`
  34. Krbextradata []struct {
  35. Base64 string `json:"__base64__"`
  36. } `json:"krbextradata"`
  37. Mail []string `json:"mail"`
  38. MemberofindirectHbacrule []string `json:"memberofindirect_hbacrule"`
  39. Dn string `json:"dn"`
  40. Displayname []string `json:"displayname"`
  41. Mepmanagedentry []string `json:"mepmanagedentry"`
  42. Ipauniqueid []string `json:"ipauniqueid"`
  43. Krbloginfailedcount []string `json:"krbloginfailedcount"`
  44. Krbpwdpolicyreference []string `json:"krbpwdpolicyreference"`
  45. Krbprincipalname []string `json:"krbprincipalname"`
  46. Givenname []string `json:"givenname"`
  47. Krblastadminunlock []struct {
  48. Datetime string `json:"__datetime__"`
  49. } `json:"krblastadminunlock"`
  50. Krbpasswordexpiration []struct {
  51. Datetime string `json:"__datetime__"`
  52. } `json:"krbpasswordexpiration"`
  53. Krblastfailedauth []struct {
  54. Datetime string `json:"__datetime__"`
  55. } `json:"krblastfailedauth"`
  56. Objectclass []string `json:"objectclass"`
  57. Gidnumber []string `json:"gidnumber"`
  58. Gecos []string `json:"gecos"`
  59. Sn []string `json:"sn"`
  60. MemberofSudorule []string `json:"memberof_sudorule"`
  61. Krblastpwdchange []struct {
  62. Datetime string `json:"__datetime__"`
  63. } `json:"krblastpwdchange"`
  64. Initials []string `json:"initials"`
  65. } `json:"result"`
  66. Value string `json:"value"`
  67. Summary interface{} `json:"summary"`
  68. } `json:"result"`
  69. Version string `json:"version"`
  70. Error interface{} `json:"error"`
  71. ID int `json:"id"`
  72. Principal string `json:"principal"`
  73. }
  74. var User = userInfo{}
  75. func (h *handler) login(c echo.Context) error {
  76. username := c.FormValue("username")
  77. password := c.FormValue("password")
  78. _url := URL + "/ipa/session/login_password"
  79. method := "POST"
  80. params := url.Values{}
  81. params.Add("user", username)
  82. params.Add("password", password)
  83. payload := strings.NewReader(params.Encode())
  84. tr := &http.Transport{
  85. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  86. }
  87. client := &http.Client{Transport: tr}
  88. req, err := http.NewRequest(method, _url, payload)
  89. audit("Recieved Login request from: " + RealIP)
  90. if err != nil {
  91. fmt.Println(err)
  92. }
  93. req.Header.Add("Referer", URL+"/ipa")
  94. req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
  95. req.Header.Add("Accept", "text/plain")
  96. res, err := client.Do(req)
  97. cockie := res.Cookies()
  98. token := cockie[0].Raw
  99. ba := basicAuth(username, password)
  100. token = token + "Basic " + ba + ";"
  101. //fmt.Println("Token:", token)
  102. defer res.Body.Close()
  103. //fmt.Println(res.StatusCode)
  104. if res.StatusCode == 200 {
  105. User = getUserInfo(token, username)
  106. //fmt.Println(user.Result)
  107. tokens, err := generateTokenPair(User, token)
  108. if err != nil {
  109. return err
  110. }
  111. return c.JSON(http.StatusOK, tokens)
  112. }
  113. return echo.ErrUnauthorized
  114. }
  115. func getUserInfo(token string, username string) userInfo {
  116. fmt.Println("Checking for User: ", username)
  117. url := URL + "/ipa/session/json"
  118. method := "POST"
  119. _json := fmt.Sprintf(`
  120. {
  121. "method": "user_show",
  122. "params": [
  123. [
  124. "%s"
  125. ],
  126. {
  127. "all": true,
  128. "version": "2.215"
  129. }
  130. ],
  131. "id": 0
  132. }
  133. `, username)
  134. payload := strings.NewReader(_json)
  135. tr := &http.Transport{
  136. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  137. }
  138. client := &http.Client{Transport: tr}
  139. req, err := http.NewRequest(method, url, payload)
  140. if err != nil {
  141. fmt.Println(err)
  142. }
  143. req.Header.Add("Referer", URL+"/ipa")
  144. req.Header.Add("Content-Type", "application/json")
  145. req.Header.Add("Accept", "text/plain")
  146. req.Header.Add("Cookie", token)
  147. res, err := client.Do(req)
  148. defer res.Body.Close()
  149. body, err := ioutil.ReadAll(res.Body)
  150. fmt.Println("Getting Data for Response: ", res.Status)
  151. user := userInfo{}
  152. json.Unmarshal(body, &user)
  153. fmt.Println("Getting Data for User: ", user.Result.Result.Uidnumber)
  154. return user
  155. }
  156. func (h *handler) uuidgen(c echo.Context) error {
  157. resource := c.FormValue("resource")
  158. id,code := uuidgen(resource)
  159. resp := _response{
  160. Origin: "uuidgen",
  161. Message: id,
  162. Code: code,
  163. }
  164. b, _ := json.MarshalIndent(resp, "", " ")
  165. return c.String(http.StatusOK, string(b))
  166. }
  167. func (h *handler) addUser(c echo.Context) error {
  168. type apiErr struct {
  169. Result interface{} `json:"result"`
  170. Error struct {
  171. Code int `json:"code"`
  172. Message string `json:"message"`
  173. Data struct {
  174. } `json:"data"`
  175. Name string `json:"name"`
  176. } `json:"error"`
  177. ID int `json:"id"`
  178. Principal string `json:"principal"`
  179. Version string `json:"version"`
  180. }
  181. type addUser struct {
  182. Result struct {
  183. Result struct {
  184. Displayname []string `json:"displayname"`
  185. UID []string `json:"uid"`
  186. Uidnumber []string `json:"uidnumber"`
  187. Objectclass []string `json:"objectclass"`
  188. Sn []string `json:"sn"`
  189. Telephonenumber []string `json:"telephonenumber"`
  190. Cn []string `json:"cn"`
  191. Krbpasswordexpiration []struct {
  192. Datetime string `json:"__datetime__"`
  193. } `json:"krbpasswordexpiration"`
  194. Mobile []string `json:"mobile"`
  195. Krbprincipalname []string `json:"krbprincipalname"`
  196. Ipauniqueid []string `json:"ipauniqueid"`
  197. Givenname []string `json:"givenname"`
  198. Gidnumber []string `json:"gidnumber"`
  199. Krbcanonicalname []string `json:"krbcanonicalname"`
  200. Mail []string `json:"mail"`
  201. Initials []string `json:"initials"`
  202. Homedirectory []string `json:"homedirectory"`
  203. Loginshell []string `json:"loginshell"`
  204. Gecos []string `json:"gecos"`
  205. Randompassword string `json:"randompassword"`
  206. HasPassword bool `json:"has_password"`
  207. HasKeytab bool `json:"has_keytab"`
  208. MemberofGroup []string `json:"memberof_group"`
  209. Dn string `json:"dn"`
  210. } `json:"result"`
  211. Value string `json:"value"`
  212. Summary string `json:"summary"`
  213. } `json:"result"`
  214. Error string `json:"error"`
  215. ID int `json:"id"`
  216. Principal string `json:"principal"`
  217. Version string `json:"version"`
  218. }
  219. user := c.Get("user").(*jwt.Token)
  220. claims := user.Claims.(jwt.MapClaims)
  221. _sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
  222. var hashChannel_ = make(chan []byte, 1)
  223. hashChannel_ <- _sha256[:]
  224. token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
  225. b, err := json.Marshal(claims)
  226. if err != nil {
  227. fmt.Println("err:", err)
  228. }
  229. //fmt.Println("AddUser Claims: ", claims)
  230. //fmt.Println("AddUser token: ", token)
  231. username := c.FormValue("Username")
  232. sha256 := sha256.Sum256([]byte(username))
  233. var hashChannel = make(chan []byte, 1)
  234. hashChannel <- sha256[:]
  235. ciphertext := encrypt(<-hashChannel, string(b))
  236. //fmt.Println("B: ", string(b))
  237. //fmt.Println("Ciphere: ", ciphertext)
  238. sn := c.FormValue("Lname")
  239. cn := c.FormValue("FullName")
  240. givenname := c.FormValue("Fname")
  241. displayname := c.FormValue("displayname")
  242. krbpasswordexpiration := c.FormValue("krbpasswordexpiration")
  243. mail := c.FormValue("mail")
  244. telephonenumber := c.FormValue("telephonenumber")
  245. mobile := c.FormValue("mobile")
  246. _url := URL + "/ipa/session/json"
  247. method := "POST"
  248. _json := fmt.Sprintf(`
  249. {
  250. "id": 0,
  251. "method": "user_add/1",
  252. "params": [
  253. [
  254. "%s"
  255. ],
  256. {
  257. "givenname": "%s",
  258. "sn": "%s",
  259. "cn":"%s",
  260. "displayname":"%s",
  261. "loginshell":"/usr/sbin/nologin",
  262. "krbpasswordexpiration":"%s",
  263. "mail":"%s",
  264. "random":"true",
  265. "gidnumber":"599200001",
  266. "telephonenumber":"%s",
  267. "mobile":"%s",
  268. "version": "2.235"
  269. }
  270. ]
  271. }
  272. `, username, givenname, sn, cn, displayname, krbpasswordexpiration, mail, telephonenumber, mobile)
  273. __json := fmt.Sprintf(`
  274. {
  275. "id": 0,
  276. "method": "group_add_member/1",
  277. "params": [
  278. [
  279. "svcaccounts"
  280. ],
  281. {
  282. "user": [
  283. "%s"
  284. ],
  285. "version": "2.235"
  286. }
  287. ]
  288. }
  289. `, username)
  290. payload := strings.NewReader(_json)
  291. _payload := strings.NewReader(__json)
  292. tr := &http.Transport{
  293. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  294. }
  295. client := &http.Client{Transport: tr}
  296. req, err := http.NewRequest(method, _url, payload)
  297. if err != nil {
  298. fmt.Println(err)
  299. }
  300. req.Header.Add("Referer", URL+"/ipa")
  301. req.Header.Add("Content-Type", "application/json")
  302. req.Header.Add("Accept", "text/plain")
  303. req.Header.Add("Cookie", token)
  304. res, err := client.Do(req)
  305. _req, _ := http.NewRequest(method, _url, _payload)
  306. _req.Header.Add("Referer", URL+"/ipa")
  307. _req.Header.Add("Content-Type", "application/json")
  308. _req.Header.Add("Accept", "text/plain")
  309. _req.Header.Add("Cookie", token)
  310. client.Do(_req)
  311. defer res.Body.Close()
  312. body, err := ioutil.ReadAll(res.Body)
  313. result := addUser{}
  314. _err := json.Unmarshal(body, &result)
  315. // fmt.Println(result)
  316. if _err != nil {
  317. _apiErr := apiErr{}
  318. __err := json.Unmarshal(body, &_apiErr)
  319. if __err != nil {
  320. return c.String(http.StatusBadRequest, "Error of error!!")
  321. }
  322. res2B, _ := json.Marshal(_apiErr)
  323. return c.String(http.StatusBadRequest, string(res2B))
  324. }
  325. go sendMail("Welcome to ZiCloud\r\n Your temporary link is :\r\n https://zicloud.com/reset/"+url.QueryEscape(ciphertext), "Welcome to ZiCloud", mail)
  326. resp := _response{
  327. Origin: "addUser",
  328. Message: "Done, Reset Link was sent to " + mail,
  329. Code: 1000,
  330. }
  331. b, _ = json.MarshalIndent(resp, "", " ")
  332. return c.String(http.StatusOK, string(b))
  333. }
  334. func (h *handler) disableUser(c echo.Context) error {
  335. user := c.Get("user").(*jwt.Token)
  336. claims := user.Claims.(jwt.MapClaims)
  337. _sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
  338. var hashChannel_ = make(chan []byte, 1)
  339. hashChannel_ <- _sha256[:]
  340. token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
  341. username := c.FormValue("Username")
  342. url := URL + "/ipa/session/json"
  343. method := "POST"
  344. _json := fmt.Sprintf(`
  345. {
  346. "id": 0,
  347. "method": "user_disable/1",
  348. "params": [
  349. [
  350. "%s"
  351. ],
  352. {
  353. "version": "2.235"
  354. }
  355. ]
  356. }
  357. `, username)
  358. payload := strings.NewReader(_json)
  359. tr := &http.Transport{
  360. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  361. }
  362. client := &http.Client{Transport: tr}
  363. req, err := http.NewRequest(method, url, payload)
  364. if err != nil {
  365. fmt.Println(err)
  366. }
  367. req.Header.Add("Referer", URL+"/ipa")
  368. req.Header.Add("Content-Type", "application/json")
  369. req.Header.Add("Accept", "text/plain")
  370. req.Header.Add("Cookie", token)
  371. res, err := client.Do(req)
  372. if err != nil {
  373. return c.String(http.StatusBadRequest, "Error"+err.Error())
  374. }
  375. defer res.Body.Close()
  376. resp := _response{
  377. Origin: "disableUser",
  378. Message: "Done",
  379. Code: 1000,
  380. }
  381. b, _ := json.MarshalIndent(resp, "", " ")
  382. return c.String(http.StatusOK, string(b))
  383. }
  384. func (h *handler) resetUser(c echo.Context) error {
  385. type keyJson struct {
  386. IPAToken string `json:"IPAToken"`
  387. Admin bool `json:"admin"`
  388. Exp int `json:"exp"`
  389. Memberof []string `json:"memberof"`
  390. Name string `json:"name"`
  391. Sub int `json:"sub"`
  392. }
  393. t := time.Now() //%Y%m%d%H%M%SZ
  394. t = t.Add(time.Hour * 24 * 60)
  395. username := c.FormValue("Username")
  396. password := c.FormValue("Password")
  397. key := c.FormValue("key")
  398. key, _ = url.QueryUnescape(key)
  399. _sha256 := sha256.Sum256([]byte(username))
  400. var hashChannel = make(chan []byte, 1)
  401. hashChannel <- _sha256[:]
  402. plainkey := decrypt(<-hashChannel, key)
  403. _plainkey := keyJson{}
  404. json.Unmarshal([]byte(plainkey), &_plainkey)
  405. _name := _plainkey.Name
  406. //_sha256 := sha256.Sum256([]byte(string("")))
  407. var hashChannel_ = make(chan []byte, 1)
  408. __sha256 := sha256.Sum256([]byte(_name))
  409. hashChannel_ <- __sha256[:]
  410. token := decrypt(<-hashChannel_, string(_plainkey.IPAToken))
  411. // token := _plainkey.IPAToken
  412. _url := URL + "/ipa/session/json"
  413. method := "POST"
  414. _json := fmt.Sprintf(`
  415. {
  416. "id": 0,
  417. "method": "user_mod/1",
  418. "params": [
  419. [
  420. "%s"
  421. ],
  422. {
  423. "userpassword":"%s",
  424. "version": "2.235"
  425. }
  426. ]
  427. }
  428. `, username, password)
  429. payload := strings.NewReader(_json)
  430. tr := &http.Transport{
  431. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  432. }
  433. client := &http.Client{Transport: tr}
  434. req, err := http.NewRequest(method, _url, payload)
  435. if err != nil {
  436. fmt.Println(err)
  437. }
  438. req.Header.Add("Referer", URL+"/ipa")
  439. req.Header.Add("Content-Type", "application/json")
  440. req.Header.Add("Accept", "text/plain")
  441. req.Header.Add("Cookie", token)
  442. res, err := client.Do(req)
  443. //fmt.Println(token)
  444. //fmt.Println(_json)
  445. //fmt.Println(req)
  446. //fmt.Println(res)
  447. _json = fmt.Sprintf(`
  448. {
  449. "id": 0,
  450. "method": "user_mod/1",
  451. "params": [
  452. [
  453. "%s"
  454. ],
  455. {
  456. "krbpasswordexpiration":"%s",
  457. "version": "2.235"
  458. }
  459. ]
  460. }
  461. `, username, t.Format("2006-01-02")+"Z")
  462. payload = strings.NewReader(_json)
  463. req, err = http.NewRequest(method, _url, payload)
  464. if err != nil {
  465. fmt.Println(err)
  466. }
  467. req.Header.Add("Referer", URL+"/ipa")
  468. req.Header.Add("Content-Type", "application/json")
  469. req.Header.Add("Accept", "text/plain")
  470. req.Header.Add("Cookie", token)
  471. err = nil
  472. res, err = client.Do(req)
  473. //fmt.Println(token)
  474. //fmt.Println(_json)
  475. //fmt.Println(req)
  476. //fmt.Println(res)
  477. if err != nil {
  478. return c.String(http.StatusBadRequest, "Error"+err.Error())
  479. }
  480. defer res.Body.Close()
  481. resp := _response{
  482. Origin: "resetUser",
  483. Message: "Done",
  484. Code: 1000,
  485. }
  486. b, _ := json.MarshalIndent(resp, "", " ")
  487. return c.String(http.StatusOK, string(b))
  488. }
  489. func (h *handler) dnsrecordadd(c echo.Context) error {
  490. user := c.Get("user").(*jwt.Token)
  491. claims := user.Claims.(jwt.MapClaims)
  492. _sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
  493. var hashChannel_ = make(chan []byte, 1)
  494. hashChannel_ <- _sha256[:]
  495. token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
  496. recordName := c.FormValue("recordName")
  497. record := c.FormValue("record")
  498. url := URL + "/ipa/session/json"
  499. method := "POST"
  500. _json := fmt.Sprintf(`
  501. {
  502. "id": 0,
  503. "method": "dnsrecord_add/1",
  504. "params": [
  505. [
  506. "ZI-TEL.COM",
  507. {
  508. "__dns_name__": "%s"
  509. }
  510. ],
  511. {
  512. "a_part_ip_address": "%s",
  513. "raw": true,
  514. "version": "2.235"
  515. }
  516. ]
  517. }
  518. `, recordName, record)
  519. payload := strings.NewReader(_json)
  520. tr := &http.Transport{
  521. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  522. }
  523. client := &http.Client{Transport: tr}
  524. req, err := http.NewRequest(method, url, payload)
  525. if err != nil {
  526. fmt.Println(err)
  527. }
  528. req.Header.Add("Referer", URL+"/ipa")
  529. req.Header.Add("Content-Type", "application/json")
  530. req.Header.Add("Accept", "text/plain")
  531. req.Header.Add("Cookie", token)
  532. res, err := client.Do(req)
  533. if err != nil {
  534. return c.String(http.StatusBadRequest, "Error"+err.Error())
  535. }
  536. //body, err := ioutil.ReadAll(res.Body)
  537. //_res:=result{}
  538. //json.Unmarshal(body, &_res)
  539. //fmt.Println(_res)
  540. defer res.Body.Close()
  541. resp := _response{
  542. Origin: "dnsrecordadd",
  543. Message: "Done",
  544. Code: 1000,
  545. }
  546. b, _ := json.MarshalIndent(resp, "", " ")
  547. return c.String(http.StatusOK, string(b))
  548. }
  549. func (h *handler) token(c echo.Context) error {
  550. user := c.Get("user").(*jwt.Token)
  551. claims := user.Claims.(jwt.MapClaims)
  552. _sha256 := sha256.Sum256([]byte(string(claims["name"].(string))))
  553. var hashChannel_ = make(chan []byte, 1)
  554. hashChannel_ <- _sha256[:]
  555. token := decrypt(<-hashChannel_, claims["IPAToken"].(string))
  556. username := claims["name"].(string)
  557. _user := getUserInfo(token, username)
  558. //fmt.Println(user.Result)
  559. newtokens, err := generateTokenPair(_user, token)
  560. if err != nil {
  561. return err
  562. }
  563. return c.JSON(http.StatusOK, newtokens)
  564. }
  565. func (h *handler) verifyUser(c echo.Context) error {
  566. name := c.FormValue("Username")
  567. //fmt.Println("Name: ", name)
  568. if name == "" {
  569. return c.JSON(http.StatusNotFound, "User NOT Found")
  570. }
  571. username := "admin"
  572. password := "h?_QJp5^&9FNc9w="
  573. _url := URL + "/ipa/session/login_password"
  574. method := "POST"
  575. params := url.Values{}
  576. params.Add("user", username)
  577. params.Add("password", password)
  578. payload := strings.NewReader(params.Encode())
  579. tr := &http.Transport{
  580. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  581. }
  582. client := &http.Client{Transport: tr}
  583. req, err := http.NewRequest(method, _url, payload)
  584. audit("Recieved Login request from: " + RealIP)
  585. if err != nil {
  586. fmt.Println(err)
  587. }
  588. req.Header.Add("Referer", URL+"/ipa")
  589. req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
  590. req.Header.Add("Accept", "text/plain")
  591. res, err := client.Do(req)
  592. cockie := res.Cookies()
  593. token := cockie[0].Raw
  594. defer res.Body.Close()
  595. //fmt.Println(token)
  596. if res.StatusCode == 200 {
  597. user := getUserInfo(token, name)
  598. if user.Result.Value != name {
  599. resp := _response{
  600. Origin: "VerifyUser",
  601. Message: "User Not Found",
  602. Code: 1001,
  603. }
  604. b, _errr := json.MarshalIndent(resp, "", " ")
  605. if _errr != nil {
  606. fmt.Println(_errr)
  607. }
  608. fmt.Print(string(b))
  609. return c.JSON(http.StatusNotFound, string(b))
  610. }
  611. }
  612. resp := _response{
  613. Origin: "VerifyUser",
  614. Message: "User Found",
  615. Code: 1002,
  616. }
  617. b, _ := json.MarshalIndent(resp, "", " ")
  618. return c.JSON(http.StatusOK, string(b))
  619. }