Exemple #1
0
func (c Controller) ProfileGet(ctx context.Context, w http.ResponseWriter, r *http.Request) {
	profid, _ := middle.CtxParam(ctx, "profid")

	profile, err := c.stg.ProfileGet(ctx, profid)
	if c.dbErrOrEmpty(w, err, io.ERR_NOPROF) {
		return
	}

	io.Output(w, profile)
}
Exemple #2
0
func (c Controller) UserConfirm(ctx context.Context, w http.ResponseWriter, r *http.Request) {
	userid, _ := middle.CtxParam(ctx, "userid")

	// execute getAndModify on storage
	fields := model.Fields{"confirm": true}
	filter := model.Fields{"confirm": false}
	user, err := c.stg.UserSet(ctx, userid, fields, filter)
	if c.dbErrOrEmpty(w, err, io.ERR_NOUSER) {
		return
	}

	// success
	resp := map[string]string{
		"message": "You are able to edit profile",
		"id":      user.ID,
	}
	io.Output(w, resp)
}