Esempio n. 1
0
func (c SigninPost) checkUserPassword(a *app.App, email, password string) (bool, db.User, error) {
	u, hash, err := a.DB().GetUserByEmail(email)
	if err != nil {
		return false, db.User{}, err
	}

	err = bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
	if err != nil {
		return false, db.User{}, err
	}
	return err == nil, u, err
}
Esempio n. 2
0
func main() {
	var a app.App
	a.Init()
	a.StartJobs()

	declareWebRoutes(&a)
	declareApiRoutes(&a)
	a.Listen()
}
Esempio n. 3
0
func declareApiRoutes(a *app.App) {
	a.AddApi("/today/{subreddit}", LogRoute(a, TodayHandler{a}), "GET")
	a.AddApi("/article/{subreddit}/{articleId}", LogRoute(a, ArticleHandler{a}), "GET")
	a.AddApi("/annotate/{subreddit}", LogRoute(a, AnnotateHandler{a}), "POST")
}
Esempio n. 4
0
func declareWebRoutes(a *app.App) {
	a.Add("/audiences/{subreddit}", web.Audiences{a}, "GET")

	a.Add("/register", web.RegisterGet{a}, "GET")
	a.Add("/register", web.RegisterPost{a}, "POST")

	a.Add("/signin", web.SigninGet{a}, "GET")
	a.Add("/signin", web.SigninPost{a}, "POST")

	a.Add("/account", web.Account{a}, "GET")
	a.Add("/logout", web.Logout{a}, "GET")

	a.Add("/index", web.Index{a}, "GET")
	a.Add("/", web.Index{a}, "GET")
}