fix auth responses

main
Gabe Farrell 3 years ago
parent 131e34ca84
commit 7524edbce4

@ -82,6 +82,7 @@ func CreateAccount(w http.ResponseWriter, r *http.Request) {
// return the account information to the user // return the account information to the user
ret, err := json.Marshal(LoginResponse{ ret, err := json.Marshal(LoginResponse{
Status: 200,
Email: v.Email, Email: v.Email,
Name: v.Name, Name: v.Name,
Session: v.Session, Session: v.Session,

@ -18,6 +18,7 @@ import (
) )
type LoginResponse struct { type LoginResponse struct {
Status int `json:"status"`
Name string `json:"name"` Name string `json:"name"`
Email string `json:"email"` Email string `json:"email"`
Session string `json:"session"` Session string `json:"session"`
@ -90,6 +91,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
update := bson.D{primitive.E{Key: "$set", Value: bson.D{primitive.E{Key: "session", Value: sessionID}}}} update := bson.D{primitive.E{Key: "$set", Value: bson.D{primitive.E{Key: "session", Value: sessionID}}}}
userCollection.UpdateOne(context.TODO(), filter, update, opts) userCollection.UpdateOne(context.TODO(), filter, update, opts)
account.Status = 200
acc, err := json.Marshal(account) acc, err := json.Marshal(account)
if err != nil { if err != nil {
fmt.Println("Error marshalling bson.D response") fmt.Println("Error marshalling bson.D response")

@ -12,8 +12,9 @@ import (
) )
type UserInfoResponse struct { type UserInfoResponse struct {
Name string `json:"name" bson:"name"` Status int `json:"status"`
Email string `json:"email" bson:"email"` Name string `json:"name" bson:"name"`
Email string `json:"email" bson:"email"`
} }
func UserInfo(w http.ResponseWriter, r *http.Request) { func UserInfo(w http.ResponseWriter, r *http.Request) {
@ -40,8 +41,9 @@ func UserInfo(w http.ResponseWriter, r *http.Request) {
} }
info := UserInfoResponse{ info := UserInfoResponse{
Name: user.Name, Status: 200,
Email: user.Email, Name: user.Name,
Email: user.Email,
} }
ret, err := json.Marshal(info) ret, err := json.Marshal(info)

Loading…
Cancel
Save