Skip to content
This repository has been archived by the owner on Apr 24, 2018. It is now read-only.

Commit

Permalink
Updated user.User to include additional attributes (map string)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Jan 20, 2013
1 parent cc6751a commit 0eb2fa1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions exp/user/user.go
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 0eb2fa1

Please sign in to comment.