You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
676 B

  1. package Auth
  2. import (
  3. "encoding/json"
  4. "log"
  5. "net/http"
  6. "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Models"
  7. "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Util"
  8. )
  9. func Me(w http.ResponseWriter, r *http.Request) {
  10. var (
  11. userData Models.User
  12. returnJson []byte
  13. err error
  14. )
  15. userData, err = CheckCookieCurrentUser(w, r)
  16. if err != nil {
  17. Util.JsonReturn(w, 401, "NO ERROR")
  18. return
  19. }
  20. returnJson, err = json.MarshalIndent(userData, "", " ")
  21. if err != nil {
  22. log.Printf("An error occured: %s\n", err.Error())
  23. Util.JsonReturn(w, 500, "An error occured")
  24. return
  25. }
  26. // Return updated json
  27. w.WriteHeader(http.StatusOK)
  28. w.Write(returnJson)
  29. }