~evanj/cms

c0e6425139922453aaed202fd12253eeb6de14c6 — Evan J 8 months ago 630f31a tmp2
WIP(email): Email support for reset password.
M internal/c/content/content.go => internal/c/content/content.go +2 -1
@@ 37,7 37,8 @@ var (
// request/response handling. External server requests have a timeout of ten
// seconds.
func bgctx() context.Context {
	ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	_ = cancel // Timeout will end downstream work.
	return ctx
}


M internal/c/user/user.go => internal/c/user/user.go +37 -1
@@ 27,11 27,17 @@ type User struct {
	db            dber
	signupEnabled bool
	stripe        Striper
	email         Emailer
}

type Emailer interface {
	Send(to, sub, msg string) error
}

type dber interface {
	UserNew(ctx context.Context, username, password, verifyPassword string) (user.User, error)
	UserGet(ctx context.Context, username, password string) (user.User, error)
	UserGetFromEmail(ctx context.Context, email string) (user.User, error)
	UserGetFromToken(ctx context.Context, token string) (user.User, error)
	UserSetEmail(ctx context.Context, u user.User, email string) (user.User, error)
	UserSetPassword(ctx context.Context, u user.User, current, password, verify string) (user.User, error)


@@ 43,13 49,14 @@ type Striper interface {
	CancelSubscription(ctx context.Context, user user.User) error
}

func New(c *c.Controller, log *log.Logger, db dber, signupEnabled bool, s Striper) *User {
func New(c *c.Controller, log *log.Logger, db dber, signupEnabled bool, s Striper, e Emailer) *User {
	return &User{
		c,
		log,
		db,
		signupEnabled,
		s,
		e,
	}
}



@@ 58,6 65,32 @@ func (l *User) logout(w http.ResponseWriter, r *http.Request) {
	l.Redirect(w, r, "/")
}

// forgot handles a request from user that user forgot password.
// An email will utlimately be sent to user, if user has an email
// associated with their account, which is not guaranteed.
func (l *User) forgot(w http.ResponseWriter, r *http.Request) {
	// TODO: Finish this impl.

	var (
		email   = r.FormValue("email")
		subject = "Skipper: forgot password link"
		message = "This functionality is not complete..."
	)

	user, err := l.db.UserGetFromEmail(r.Context(), email)
	if err != nil {
		l.Error(w, r, http.StatusNotFound, err)
		return
	}

	if err := l.email.Send(user.Email(), subject, message); err != nil {
		l.Error(w, r, http.StatusInternalServerError, err)
		return
	}

	l.Redirect(w, r, "/")
}

func (l *User) login(w http.ResponseWriter, r *http.Request) {
	username := r.FormValue("username")
	password := r.FormValue("password")


@@ 225,6 258,9 @@ func (l *User) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	case "/":
		l.home(w, r)
		return
	case "/user/forgot":
		l.forgot(w, r)
		return
	case "/user/login":
		l.login(w, r)
		return

M internal/s/db/user.go => internal/s/db/user.go +45 -0
@@ 28,6 28,16 @@ type User struct {
var (
	queryCreateNewUser = `INSERT INTO cms_user (NAME, HASH, ORG_ID, ROLE_ID) VALUES (?, ?, ?, (SELECT cms_role.ID FROM cms_role WHERE VALUE=?))`

	queryFindUserByEmail = `
		SELECT cms_user.ID, NAME, HASH, EMAIL, cms_org.ID, cms_billing.TIER_NAME, cms_billing.PAYMENT_CUSTOMER, cms_role.ID, cms_role.VALUE
		FROM cms_user 
		JOIN cms_org ON cms_org.ID=cms_user.ORG_ID
		join cms_role ON cms_role.ID=cms_user.ROLE_ID
		LEFT JOIN cms_billing ON cms_billing.ORG_ID=cms_org.ID
		LEFT JOIN cms_email ON cms_email.USER_ID=cms_user.ID 
		WHERE cms_email.EMAIL = ?
	`

	queryFindUserByID = `
		SELECT cms_user.ID, NAME, HASH, EMAIL, cms_org.ID, cms_billing.TIER_NAME, cms_billing.PAYMENT_CUSTOMER, cms_role.ID, cms_role.VALUE
		FROM cms_user 


@@ 137,6 147,41 @@ func (db *DB) userGet(ctx context.Context, t *sql.Tx, username, password string)
	return &user, nil
}

func (db *DB) UserGetFromEmail(ctx context.Context, email string) (user.User, error) {
	t, err := db.BeginTx(ctx, nil)
	if err != nil {
		return nil, err
	}
	defer t.Rollback()

	user, err := db.userGetFromEmail(ctx, t, email)
	if err != nil {
		return nil, err
	}

	return user, t.Commit()
}

func (db *DB) userGetFromEmail(ctx context.Context, t *sql.Tx, email string) (user.User, error) {
	var user User
	if err := t.QueryRowContext(ctx, queryFindUserByEmail, email).Scan(
		&user.UserID, &user.UserName, &user.userHash, &user.userEmail,
		&user.UserOrg.OrgID, &user.UserOrg.OrgBillingTierName, &user.UserOrg.OrgPaymentCustomer,
		&user.UserRole.RoleID, &user.UserRole.RoleName,
	); err != nil {
		fmt.Println(err)
		return nil, fmt.Errorf("failed to find user")
	}

	tok, err := db.sec.TokenCreate(security.TokenMap{"ID": user.UserID})
	if err != nil {
		return nil, fmt.Errorf("failed to create token for user")
	}

	user.userToken = tok
	return &user, nil
}

func (db *DB) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	t, err := db.BeginTx(ctx, nil)
	if err != nil {

A internal/s/email/email.go => internal/s/email/email.go +54 -0
@@ 0,0 1,54 @@
package email

import (
	"bytes"
	"fmt"
	"html/template"
	"net/smtp"
)

type Email struct {
	from, domain string
	port         int
	auth         smtp.Auth
	tmpl         *template.Template
}

func New(username, password, from, domain string, port int) Email {
	var (
		ident      string
		tmplSource = "From: {{.From}}\r\nTo: {{.To}}\r\nSubject: {{.Subject}}\r\n\r\n{{.Body}}\r\n"
		tmpl       = template.Must(template.New("").Parse(tmplSource))
	)

	return Email{
		from,
		domain,
		port,
		smtp.PlainAuth(ident, username, password, domain),
		tmpl,
	}
}

func (e Email) Send(to, sub, msg string) error {
	var (
		buf  bytes.Buffer
		addr = fmt.Sprintf("%s:%d", e.domain, e.port)
		data = map[string]string{
			"From":    e.from,
			"To":      to,
			"Subject": sub,
			"Body":    msg,
		}
	)

	if err := e.tmpl.Execute(&buf, data); err != nil {
		return err
	}

	if err := smtp.SendMail(addr, e.auth, e.from, []string{to}, buf.Bytes()); err != nil {
		return err
	}

	return nil
}

A internal/s/email/email_test.go => internal/s/email/email_test.go +1 -0
@@ 0,0 1,1 @@
package email_test

M internal/v/html/_footer.html => internal/v/html/_footer.html +2 -0
@@ 102,6 102,8 @@
              </select>
            </div>
          </div>
          <p class='mt-3 mb-0'>For more information about what each specific role is allowed 
          <a target='_blank' href='/roles'>please read the roles guide.</a></p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

M internal/v/tmpls_embed.go => internal/v/tmpls_embed.go +1 -1
@@ 20,7 20,7 @@ func init() {

	tmpls["css/mvp.css"] = tostring("OnJvb3QgewogICAgLS1ib3JkZXItcmFkaXVzOiA1cHg7CiAgICAtLWJveC1zaGFkb3c6IDJweCAycHggMTBweDsKICAgIC0tY29sb3I6ICMxMThiZWU7CiAgICAtLWNvbG9yLWFjY2VudDogIzExOGJlZTBiOwogICAgLS1jb2xvci1iZzogI2ZmZjsKICAgIC0tY29sb3ItYmctc2Vjb25kYXJ5OiAjZTllOWU5OwogICAgLS1jb2xvci1zZWNvbmRhcnk6ICM5MjBkZTk7CiAgICAtLWNvbG9yLXNlY29uZGFyeS1hY2NlbnQ6ICM5MjBkZTkwYjsKICAgIC0tY29sb3Itc2hhZG93OiAjZjRmNGY0OwogICAgLS1jb2xvci10ZXh0OiAjMDAwOwogICAgLS1jb2xvci10ZXh0LXNlY29uZGFyeTogIzk5OTsKICAgIC0taG92ZXItYnJpZ2h0bmVzczogMS4yOwogICAgLS1qdXN0aWZ5LWltcG9ydGFudDogY2VudGVyOwogICAgLS1qdXN0aWZ5LW5vcm1hbDogbGVmdDsKICAgIC0tbGluZS1oZWlnaHQ6IDE1MCU7CiAgICAtLXdpZHRoLWNhcmQ6IDI4NXB4OwogICAgLS13aWR0aC1jYXJkLW1lZGl1bTogNDYwcHg7CiAgICAtLXdpZHRoLWNhcmQtd2lkZTogODAwcHg7CiAgICAtLXdpZHRoLWNvbnRlbnQ6IDEwODBweDsKfQoKLyogTVZQLmNzcyB2MS4wIC0gYnkgQW5keSBCcmV3ZXIgKi8KCi8qIExheW91dCAqLwphcnRpY2xlIGFzaWRlIHsKICAgIGJhY2tncm91bmQ6IHZhcigtLWNvbG9yLXNlY29uZGFyeS1hY2NlbnQpOwogICAgYm9yZGVyLWxlZnQ6IDRweCBzb2xpZCB2YXIoLS1jb2xvci1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cms/internal/c/user"
	"git.sr.ht/~evanj/cms/internal/s/cache"
	"git.sr.ht/~evanj/cms/internal/s/db"
	"git.sr.ht/~evanj/cms/internal/s/email"
	webhook "git.sr.ht/~evanj/cms/internal/s/hook"
	"git.sr.ht/~evanj/cms/internal/s/rbac"
	"git.sr.ht/~evanj/cms/internal/s/rl"


@@ 57,6 58,10 @@ var (
	dynamicContentURL         = os.Getenv("DYNAMIC_CONTENT_URL")
	dynamicContentSpace       = mustInt(os.Getenv("DYNAMIC_CONTENT_SPACE"))
	dynamicContentContentType = mustInt(os.Getenv("DYNAMIC_CONTENT_CONTENTTYPE"))
	emailUser                 = os.Getenv("EMAIL_USER")
	emailPass                 = os.Getenv("EMAIL_PASS")
	emailDomain               = os.Getenv("EMAIL_DOMAIN")
	emailPort                 = mustInt(os.Getenv("EMAIL_PORT"))
)

func mustInt(val string) int {


@@ 72,6 77,8 @@ func main() {
		w         = os.Stdout
		applogger = log.New(w, "[cms] ", 0)

		emailer = email.New(emailUser, emailPass, emailUser, emailDomain, emailPort)

		db = db.New(
			log.New(w, "[cms:db] ", 0),
			dbtype,


@@ 130,6 137,7 @@ func main() {
					rbac,
					signupEnabled,
					libs,
					emailer,
				),
				"hook": hook.New(
					c,