Exemple #1
0
func OfSession(session *view.Session, resultRef interface{}) (found bool, err error) {
	id := session.ID()
	if id == "" {
		return false, nil
	}
	return WithID(id, resultRef)
}
Exemple #2
0
// Returns nil if there is no session user
func OfSession(session *view.Session) (userDoc interface{}) {
	if session.User != nil {
		return session.User
	}
	id, ok := session.ID()
	if !ok {
		return nil
	}
	userDoc, _, _ = FindByID(id)
	session.User = userDoc
	return userDoc
}
Exemple #3
0
func Logout(session *view.Session) {
	session.DeleteID()
	session.User = nil
}
Exemple #4
0
func Login(session *view.Session, userDoc interface{}) {
	session.SetID(userDoc.(mongo.Document).ObjectId().Hex())
	session.User = userDoc
}
Exemple #5
0
func LoggedIn(session *view.Session) bool {
	return session.ID() != ""
}
Exemple #6
0
func LoginID(session *view.Session, id string) {
	session.SetID(id)
}
Exemple #7
0
func Logout(session *view.Session) {
	session.DeleteID()
}