Exemple #1
0
// login user
func LoginUser(user *models.User, ctx *tango.Context, session *session.Session, remember bool) {
	// werid way of beego session regenerate id...
	//session.SessionRelease(ctx.ResponseWriter)
	//session = beego.GlobalSessions.SessionRegenerateId(ctx.ResponseWriter, ctx.Req())
	fmt.Println("user:"******"auth_user_id", user.Id)

	if remember {
		WriteRememberCookie(user, ctx)
	}
}
Exemple #2
0
func GetUserIdFromSession(sess *session.Session) int64 {
	if id, ok := sess.Get("auth_user_id").(int64); ok {
		return id
	}
	return 0
}
Exemple #3
0
// logout user
func LogoutUser(ctx *tango.Context, sess *session.Session) {
	DeleteRememberCookie(ctx)
	sess.Del("auth_user_id")
}