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
ret, err := json.Marshal(LoginResponse{
Status: 200,
Email: v.Email,
Name: v.Name,
Session: v.Session,

@ -18,6 +18,7 @@ import (
)
type LoginResponse struct {
Status int `json:"status"`
Name string `json:"name"`
Email string `json:"email"`
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}}}}
userCollection.UpdateOne(context.TODO(), filter, update, opts)
account.Status = 200
acc, err := json.Marshal(account)
if err != nil {
fmt.Println("Error marshalling bson.D response")

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

Loading…
Cancel
Save