Esempio n. 1
0
func (vars V) LogIn(u *user.User) {
	if u == nil {
		vars.LogOut()
	} else {
		sessioner.V(vars).Set("CurrentUser", u.ClashTag)
		vars["CurrentUser"] = u
	}
}
Esempio n. 2
0
func (this NewUserForm) Run(vars map[string]interface{}, next func()) {
	s := sessioner.V(vars)
	s.Set("authorization", this.Authorization)
	s.Set("auth_id", this.Id)
	s.Set("access", this.Token.AccessToken)
	s.Set("refresh", this.Token.RefreshToken)
	s.Set("expiry", this.Token.Expiry.Format(time.RFC1123))

	(redirecter.V)(vars).Redirect("/users/new")
}
Esempio n. 3
0
func (this TokenHandler) Run(vars map[string]interface{}, next func()) {
	if this.tok == nil {
		sessioner.V(vars).AddFlash("Log In Cancelled")
		(redirecter.V)(vars).Redirect("/")
		return
	}

	authorization := this.a.GetName()
	id := this.a.GetUserID(this.tok)

	u := user.U.UserFromAuthorization(authorization, id)
	if u != nil {
		//if we find a user, log them in
		(V)(vars).LogIn(u)
		(sessioner.V)(vars).AddFlash("Welcome back, " + u.ClashTag)
		(redirecter.V)(vars).Redirect("/")
	} else {
		//otherwise, have them fill out the New User Form!
		NewUserForm{Token: *this.tok, Authorization: authorization, Id: id}.Run(vars, next)
	}
}