diff options
Diffstat (limited to 'user/db_actions.go')
-rw-r--r-- | user/db_actions.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/user/db_actions.go b/user/db_actions.go index 2d89b7e..51490e7 100644 --- a/user/db_actions.go +++ b/user/db_actions.go @@ -46,3 +46,15 @@ func modifyUser(id primitive.ObjectID, nu User) error { _, err := db.UpdateOne(context.TODO(), bson.D{{"_id", id}}, bson.D{{"$set", nu}}) return err } + +// gets user info +func getUser(userId primitive.ObjectID) (User, error) { + var user User + err := db.FindOne(context.TODO(), bson.D{{"_id", userId}}).Decode(&user) + + // remove sensitive data + user.Password = "" + user.Sessions = []Session{} + + return user, err +} |