Пример #1
0
func Test_Handler_clearSession(t *testing.T) {
	var ok bool

	config := util.NewMzConfig()
	h, _ := testHandler(config, t)
	sess := new(sessions.Session)
	sess.Values = make(map[interface{}]interface{})
	sess.Values[SESSION_USERID] = true
	sess.Values[SESSION_DEVICEID] = true
	sess.Values[SESSION_EMAIL] = true
	sess.Values[SESSION_TOKEN] = true
	sess.Values[SESSION_CSRFTOKEN] = true
	h.clearSession(sess)
	if _, ok = sess.Values[SESSION_USERID]; ok {
		t.Errorf("Userid not cleared")
	}
	if _, ok = sess.Values[SESSION_DEVICEID]; ok {
		t.Errorf("Deviceid not cleared")
	}
	if _, ok = sess.Values[SESSION_EMAIL]; ok {
		t.Errorf("Email not cleared")
	}
	if _, ok = sess.Values[SESSION_TOKEN]; ok {
		t.Errorf("Token not cleared")
	}
	if _, ok = sess.Values[SESSION_CSRFTOKEN]; ok {
		t.Errorf("CSRFToken not cleared")
	}
}
Пример #2
0
func (s *RAMStore) load(session *sessions.Session) error {
	sessionData, err := s.getData().GetData(session.ID)
	if err != nil {
		return err
	}
	if sessionData != nil {
		session.Values = sessionData
		session.IsNew = false
	}
	return nil
}
Пример #3
0
func (c *AppController) GetNotice(session *sessions.Session) string {
	msg := session.Values["notice"]

	newVal := make(map[interface{}]interface{})

	for k, v := range session.Values {
		if k != "notice" {
			newVal[k] = v
		}
	}
	session.Values = newVal

	if msg != nil {
		return msg.(string)
	} else {
		return ""
	}
}
Пример #4
0
func (c *AppController) ClearUserSession(session *sessions.Session) {
	session.Values = make(map[interface{}]interface{})
}