From 0eb2fa13e9f4139e803b6ad37831708d4786c74a Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Sat, 19 Jan 2013 23:37:30 -0700 Subject: [PATCH] Updated user.User to include additional attributes (map string) --- exp/user/user.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/exp/user/user.go b/exp/user/user.go index 79c1acd..eaf4422 100644 --- a/exp/user/user.go +++ b/exp/user/user.go @@ -17,6 +17,9 @@ type User struct { FederatedIdentity string FederatedProvider string + + // additional, custom Attributes + Attrs map[string]string } // Decode will create a user from a URL Query string. @@ -26,17 +29,31 @@ func Decode(v string) *User { return nil } + attrs := map[string]string{} + for key, _ := range values { + attrs[key]=values.Get(key) + } + return &User { Id : values.Get("id"), Name : values.Get("name"), Email : values.Get("email"), Photo : values.Get("photo"), + Attrs : attrs, } } // Encode will encode a user as a URL query string. func (u *User) Encode() string { values := url.Values{} + + // add custom attributes + if u.Attrs != nil { + for key, val := range u.Attrs { + values.Set(key, val) + } + } + values.Set("id", u.Id) values.Set("name", u.Name) values.Set("email", u.Email)