Remove sensitive information from LoggedUser endpoint
This commit is contained in:
@@ -68,7 +68,7 @@ func Register(extend HandlerExtender) {
|
|||||||
http.ServeFile(rw, r, "./www/landing.html")
|
http.ServeFile(rw, r, "./www/landing.html")
|
||||||
}).Methods("GET")
|
}).Methods("GET")
|
||||||
|
|
||||||
corsRouter.HandleFunc("/users/me", LoggedInUser).Methods("GET")
|
corsRouter.HandleFunc("/users/me", GetUser).Methods("GET")
|
||||||
r.HandleFunc("/users/{userId:^(?me)}", GetUser).Methods("GET")
|
r.HandleFunc("/users/{userId:^(?me)}", GetUser).Methods("GET")
|
||||||
r.HandleFunc("/oauth/providers", ListProviders).Methods("GET")
|
r.HandleFunc("/oauth/providers", ListProviders).Methods("GET")
|
||||||
r.HandleFunc("/oauth/providers/{provider}/login", Login).Methods("GET")
|
r.HandleFunc("/oauth/providers/{provider}/login", Login).Methods("GET")
|
||||||
|
|||||||
@@ -17,22 +17,6 @@ import (
|
|||||||
"github.com/twinj/uuid"
|
"github.com/twinj/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoggedInUser(rw http.ResponseWriter, req *http.Request) {
|
|
||||||
cookie, err := ReadCookie(req)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Cannot read cookie")
|
|
||||||
rw.WriteHeader(http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
user, err := core.UserGet(cookie.Id)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Couldn't get user with id %s. Got: %v\n", cookie.Id, err)
|
|
||||||
rw.WriteHeader(http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
json.NewEncoder(rw).Encode(user)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ListProviders(rw http.ResponseWriter, req *http.Request) {
|
func ListProviders(rw http.ResponseWriter, req *http.Request) {
|
||||||
providers := []string{}
|
providers := []string{}
|
||||||
for name, _ := range config.Providers {
|
for name, _ := range config.Providers {
|
||||||
|
|||||||
Reference in New Issue
Block a user