|
|
- package Auth
-
- import (
- "encoding/json"
- "log"
- "net/http"
-
- "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Models"
- "git.tovijaeschke.xyz/tovi/SuddenImpactRecords/Util"
- )
-
- func Me(w http.ResponseWriter, r *http.Request) {
- var (
- userData Models.User
- returnJson []byte
- err error
- )
-
- userData, err = CheckCookieCurrentUser(w, r)
- if err != nil {
- Util.JsonReturn(w, 401, "NO ERROR")
- return
- }
-
- returnJson, err = json.MarshalIndent(userData, "", " ")
- if err != nil {
- log.Printf("An error occured: %s\n", err.Error())
- Util.JsonReturn(w, 500, "An error occured")
- return
- }
-
- // Return updated json
- w.WriteHeader(http.StatusOK)
- w.Write(returnJson)
-
- }
|