From e66f12dcfe114f78f7c2dbc591d0572c1ba932f8 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Sat, 27 Mar 2021 16:27:49 +0100 Subject: [PATCH] set app id on new signups --- internal/db/db.go | 2 +- internal/db/pg.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/db/db.go b/internal/db/db.go index 4b35284..dcd7cf8 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -148,7 +148,7 @@ type DB interface { // NewSignup creates a new user in the database with the given parameters, with an *unconfirmed* email address. // By the time this function is called, it should be assumed that all the parameters have passed validation! - NewSignup(username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string) (*model.User, error) + NewSignup(username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string) (*model.User, error) /* USEFUL CONVERSION FUNCTIONS diff --git a/internal/db/pg.go b/internal/db/pg.go index 72cbd79..621f3a6 100644 --- a/internal/db/pg.go +++ b/internal/db/pg.go @@ -415,7 +415,7 @@ func (ps *postgresService) IsEmailAvailable(email string) error { return nil } -func (ps *postgresService) NewSignup(username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string) (*model.User, error) { +func (ps *postgresService) NewSignup(username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string) (*model.User, error) { key, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { ps.log.Errorf("error creating new rsa key: %s", err) @@ -444,6 +444,7 @@ func (ps *postgresService) NewSignup(username string, reason string, requireAppr SignUpIP: signUpIP, Locale: locale, UnconfirmedEmail: email, + CreatedByApplicationID: appID, } if _, err = ps.conn.Model(u).Insert(); err != nil { return nil, err