Ejemplo n.º 1
0
func (this *LoginRouter) Get() {
	// Set const
	this.Data["App_Name"] = App_Name
	// xsrf
	this.Data["xsrf"] = template.HTML(this.XsrfFormHtml())
	// set token in case twice submit
	Token := models.Token()
	this.SetSession("Token", Token)
	// set cookie not bot in case bots
	Cookies := models.RandString(20)
	this.SetSession("Cookie", Cookies)

	this.Data["Token"] = Token
	this.Data["Cookie"] = Cookies

	// Get referral
	Refer := this.Input().Get("username")
	if models.UserExist(Refer) {
		this.Data["Refer"] = Refer
	} else {
		models.Log(models.Log_Struct{"error", "Login:"******"No such referer")})
	}

	// Get User Session
	var user Session_User
	u := this.GetSession("_User")
	if u != nil {
		user = u.(Session_User)
		this.Data["User"] = user
	} else {
		this.Data["User"] = false
	}

	// Show the login page or Error page
	var showLogin bool
	v := this.GetSession("ShowLogin")
	if v != nil {
		showLogin = v.(bool)
		this.DelSession("ShowLogin")
	} else {
		showLogin = true
	}
	this.Data["ShowLogin"] = showLogin

	// Errors
	if !showLogin {
		e := this.GetSession("Error")
		if e != nil {
			this.Data["Error"] = GetError(e)
			this.DelSession("Error")
		}
	}

	this.TplNames = "login.html"
}
Ejemplo n.º 2
0
func (this *ForgetRouter) Get() {
	// Set const
	this.Data["App_Name"] = App_Name

	// xsrf
	this.Data["xsrf"] = template.HTML(this.XsrfFormHtml())

	Token := models.Token()
	this.SetSession("Token", Token)
	this.Data["Token"] = Token

	v := this.GetSession("Forget_Suc")
	if v != nil {
		this.Data["Forget_Suc"] = v.(bool)
		if !v.(bool) {
			e := this.GetSession("Error")
			if e != nil {
				this.Data["Error"] = GetError(e)
				this.DelSession("Error")
			}
		}
		this.DelSession("Forget_Suc")
	}

	// Get User Session
	var user Session_User
	u := this.GetSession("_User")
	if u != nil {
		user = u.(Session_User)
		this.Data["User"] = user
	} else {
		this.Data["User"] = false
	}

	this.TplNames = "forget.html"
}