Change session cookie delimeter to colon from pipe

This is to permit us to store a user's Groups in a pipe-delimited list
without fear of bad splits or having to reassemble it in transit.
This commit is contained in:
Brandon Matthews 2017-01-10 12:48:53 -08:00
parent af7be2d622
commit 6cbed581c2
2 changed files with 3 additions and 3 deletions

View File

@ -72,11 +72,11 @@ func (s *SessionState) EncryptedString(c *cookie.Cipher) (string, error) {
return "", err
}
}
return fmt.Sprintf("%s|%s|%d|%s", s.userOrEmail(), a, s.ExpiresOn.Unix(), r), nil
return fmt.Sprintf("%s:%s:%d:%s", s.userOrEmail(), a, s.ExpiresOn.Unix(), r), nil
}
func DecodeSessionState(v string, c *cookie.Cipher) (s *SessionState, err error) {
chunks := strings.Split(v, "|")
chunks := strings.Split(v, ":")
if len(chunks) == 1 {
if strings.Contains(chunks[0], "@") {
u := strings.Split(v, "@")[0]

View File

@ -25,7 +25,7 @@ func TestSessionStateSerialization(t *testing.T) {
}
encoded, err := s.EncodeSessionState(c)
assert.Equal(t, nil, err)
assert.Equal(t, 3, strings.Count(encoded, "|"))
assert.Equal(t, 3, strings.Count(encoded, ":"))
ss, err := DecodeSessionState(encoded, c)
t.Logf("%#v", ss)