// UpdateProfileHandler is a default handler to serve up
// a profile page.
UpdateProfileHandler is a default handler to serve up
a profile page.
// UpdateProfileHandler is a default handler to serve up // a profile page .
func UpdateProfileHandler(c buffalo.Context) error {
	u := c.Data()["current_user"].(*models.User)
	u.Name = c.Request().Form.Get("Name")
	u.Email = nulls.NewString(c.Request().Form.Get("Email"))
	u.Gender = nulls.NewString(c.Request().Form.Get("Gender"))
	u.Location = nulls.NewString(c.Request().Form.Get("Location"))
	u.Website = nulls.NewString(c.Request().Form.Get("Website"))
	tx := c.Value("tx").(*pop.Connection)
	if err := tx.Save(u); err != nil {
		return errors.WithStack(err)
	}
	c.Set("current_user", u)
	c.Flash().Add("success", "profile updated!")
	return c.Render(200, render.R.HTML("profile/profile.html"))
}
func UpdateProfileHandler ( c buffalo . Context ) error { u := c . Data ( ) [ " " ] . ( * models . User ) u . Name = c . Request ( ) . Form . Get ( " " ) u . Email = nulls . NewString ( c . Request ( ) . Form . Get ( " " ) ) u . Gender = nulls . NewString ( c . Request ( ) . Form . Get ( " " ) ) u . Location = nulls . NewString ( c . Request ( ) . Form . Get ( " " ) ) u . Website = nulls . NewString ( c . Request ( ) . Form . Get ( " " ) ) tx := c . Value ( " " ) . ( * pop . Connection ) if err := tx . Save ( u ) ; err != nil { return errors . WithStack ( err ) } c . Set ( " " , u ) c . Flash ( ) . Add ( " " , " " ) return c . Render ( 200 , render . R . HTML ( " " ) ) }
UpdateProfileHandler is a default handler to serve up
a profile page.
UpdateProfileHandler is a default handler to serve up a profile page .
// get current user details set initially by middleware