Esempio n. 1
0
func loginWithGoogle() gin.HandlerFunc {
	return func(c *gin.Context) {
		ctx := appengine.NewContext(c.Request)
		u := user.Current(ctx)
		if u == nil {
			url, _ := user.LoginURL(ctx, c.Request.URL.String())
			c.HTML(302, "login.tmpl", gin.H{
				"url": url,
			})
			c.Abort()
			return
		}
		email := strings.Split(u.Email, "@")
		if email[1] == "elo7.com" && len(email) == 2 {
			developer := models.Developer{Email: u.Email}
			developer.Create(&db)

			log.Infof(ctx, developer.Email)
		} else {
			url, _ := user.LogoutURL(ctx, "/")
			c.Redirect(http.StatusTemporaryRedirect, url)
		}
		c.Next()
	}
}
Esempio n. 2
0
func UpdatePage(c *gin.Context) {
	var developer m.Developer
	developer.LoggedUser(&db, c)
	c.HTML(http.StatusOK, "user.tmpl", gin.H{
		"developer": &developer,
	})
}
Esempio n. 3
0
func updateDevPending() gin.HandlerFunc {
	return func(c *gin.Context) {
		var developer models.Developer
		developer.LoggedUser(&db, c)
		if developer.Name == "" || developer.GithubAccount == "" {
			c.HTML(http.StatusAccepted, "user.tmpl", gin.H{
				"developer": &developer,
			})
			c.Abort()
			return
		}
	}
}