Beispiel #1
0
// Get implemented login page.
func (this *Login) Get() error {
	this.Data["IsLoginPage"] = true

	loginRedirect := strings.TrimSpace(this.GetString("to"))
	if loginRedirect == "" {
		loginRedirect = this.Ctx.Req().Header.Get("Referer")
	}
	if utils.IsMatchHost(loginRedirect) == false {
		loginRedirect = "/"
	}

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

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

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

	return this.Render("auth/login.html", this.Data)
}
Beispiel #2
0
func (this *BaseRouter) JsStorage(action, key string, values ...string) {
	value := action + ":::" + key
	if len(values) > 0 {
		value += ":::" + values[0]
	}
	auth.SetCookie(this, "JsStorage", value, 1<<31-1, "/", nil, nil, false)
}
Beispiel #3
0
func (this *BaseRouter) LoginUser(user *models.User, remember bool) string {
	ck := this.Cookies().Get("login_to")
	var loginRedirect string
	if ck != nil {
		loginRedirect = strings.TrimSpace(ck.Value)
	}
	if !utils.IsMatchHost(loginRedirect) {
		loginRedirect = "/"
	} else {
		auth.SetCookie(this, "login_to", "", -1, "/")
	}

	// login user
	auth.LoginUser(user, this.Context, &this.Session, remember)

	this.setLangCookie(i18n.GetLangByIndex(user.Lang))

	return loginRedirect
}
Beispiel #4
0
func (this *BaseRouter) setLangCookie(lang string) {
	auth.SetCookie(this, "lang", lang, 60*60*24*365, "/", nil, nil, false)
}