Exemple #1
0
func (tickets *tickets) FakeSessionToken(userid string) (st *SessionToken) {
	sid := fmt.Sprintf("fake-%s", randomstring.NewRandomString(27))
	id, _ := tickets.Encode("id", sid)
	id = tickets.reverseSessionId(id)
	st = &SessionToken{Id: id, Sid: sid, Userid: userid}
	log.Println("Created new fake session id", st.Id)
	return
}
Exemple #2
0
func (tickets *tickets) DecodeSessionToken(token string) (st *SessionToken) {
	var err error
	if token != "" {
		st = &SessionToken{}
		err = tickets.Decode(tickets.tokenName, token, st)
		if err != nil {
			log.Println("Error while decoding session token", err)
		}
	}

	if st == nil || err != nil {
		sid := randomstring.NewRandomString(32)
		id, _ := tickets.Encode("id", sid)
		id = tickets.reverseSessionId(id)
		st = &SessionToken{Id: id, Sid: sid}
		if !silentOutput {
			log.Println("Created new session id", id)
		}
	}
	return
}
Exemple #3
0
func (rooms *Rooms) Post(request *http.Request) (int, interface{}, http.Header) {

	name := randomstring.NewRandomString(11)
	return 200, &Room{name, fmt.Sprintf("/%s", name)}, http.Header{"Content-Type": {"application/json"}}

}