Exemplo n.º 1
0
// get login redirect url from cookie
func (this *BaseController) GetLoginRedirect(ctx *context.Context) string {
	loginRedirect := strings.TrimSpace(ctx.GetCookie("login_to"))
	if utils.IsMatchHost(loginRedirect) == false {
		loginRedirect = "/"
	} else {
		ctx.SetCookie("login_to", "", -1, "/")
	}
	return loginRedirect
}
Exemplo n.º 2
0
func (this *BaseController) LoginUser(u *user.User, remember bool) string {
	loginRedirect := strings.TrimSpace(this.Ctx.GetCookie("login_to"))
	if utils.IsMatchHost(loginRedirect) == false {
		loginRedirect = "/"
	} else {
		this.Ctx.SetCookie("login_to", "", -1, "/")
	}

	// login user
	this.LoginUserRememberCookie(u, this.Ctx, remember)

	//todo: add locale support, rewrite i18n.go
	this.setLangCookie(u.Lang)

	return loginRedirect
}
Exemplo n.º 3
0
// Get implemented login page.
func (this *AuthController) Get() {
	this.Data["IsLoginPage"] = true
	this.TplName = "auth/login.html"

	loginRedirect := strings.TrimSpace(this.GetString("to"))
	if utils.IsMatchHost(loginRedirect) == false {
		loginRedirect = "/"
	}

	// no need login
	if this.CheckLoginRedirect(false, loginRedirect) {
		return
	}

	if len(loginRedirect) > 0 {
		this.Ctx.SetCookie("login_to", loginRedirect, 0, "/")
	}

	form := LoginForm{}
	this.SetFormSets(&form)
}