Exemplo n.º 1
0
func awardUser(db *mgo.Database, session sessions.Session, r render.Render, x csrf.CSRF) {
	template := make(map[string]string)
	template["contactUrl"] = os.Getenv("CONTACT_URL")
	template["contactValue"] = os.Getenv("CONTACT_VALUE")
	user := session.Get("user").(string)
	status := checkStatus(db, user)
	if status == 0 {
		template["message"] = "Can't seem to find records of you :/"
		r.HTML(http.StatusUnauthorized, "error", template)
	} else if status == 1 {
		err := userHasAuth(db, user)
		if err != nil {
			log.Println(err)
			template["message"] = "Uh oh! Please report this :("
			r.HTML(http.StatusInternalServerError, "error", template)
		} else {
			r.HTML(http.StatusOK, "form", x.GetToken())
		}
	} else if status == 2 {
		r.HTML(http.StatusOK, "form", x.GetToken())
	} else if status == 3 {
		template["message"] = "Hey buddy, it seems you have been awarded before."
		r.HTML(http.StatusUnauthorized, "error", template)
	}
}
Exemplo n.º 2
0
func SignUp(s sessions.Session, r render.Render, x csrf.CSRF) {
	returnvals := map[string]interface{}{
		"csrf":  x.GetToken(),
		"Title": "Nightcrawler Signup",
	}
	r.HTML(200, "sign_up", returnvals)
}
Exemplo n.º 3
0
func SignIn(r render.Render, x csrf.CSRF, s sessions.Session) {
	r.HTML(
		200,
		"sign_in",
		map[string]interface{}{
			"Title": "Nightcrawler Sign In",
			"csrf":  x.GetToken(),
		},
	)
}
Exemplo n.º 4
0
func HTMLCSRF(x csrf.CSRF, html HTMLContext) {
	html["CSRF"] = x.GetToken()
}