Revert "Remove sensitive information from LoggedUser endpoint"
This reverts commit e91a1f3e6f.
This commit is contained in:
@@ -68,7 +68,7 @@ func Register(extend HandlerExtender) {
|
||||
http.ServeFile(rw, r, "./www/landing.html")
|
||||
}).Methods("GET")
|
||||
|
||||
corsRouter.HandleFunc("/users/me", GetUser).Methods("GET")
|
||||
corsRouter.HandleFunc("/users/me", LoggedInUser).Methods("GET")
|
||||
r.HandleFunc("/users/{userId:^(?me)}", GetUser).Methods("GET")
|
||||
r.HandleFunc("/oauth/providers", ListProviders).Methods("GET")
|
||||
r.HandleFunc("/oauth/providers/{provider}/login", Login).Methods("GET")
|
||||
|
||||
@@ -17,6 +17,22 @@ import (
|
||||
"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) {
|
||||
providers := []string{}
|
||||
for name, _ := range config.Providers {
|
||||
|
||||
Reference in New Issue
Block a user