diff --git a/pkg/models/project.go b/pkg/models/project.go index 34e3f772f..100e23bea 100644 --- a/pkg/models/project.go +++ b/pkg/models/project.go @@ -714,11 +714,22 @@ func CreateProject(s *xorm.Session, project *Project, auth web.Auth) (err error) // CreateNewProjectForUser creates a new inbox project for a user. To prevent import cycles, we can't do that // directly in the user.Create function. -func CreateNewProjectForUser(s *xorm.Session, user *user.User) (err error) { +func CreateNewProjectForUser(s *xorm.Session, u *user.User) (err error) { p := &Project{ Title: "Inbox", } - return p.Create(s, user) + err = p.Create(s, u) + if err != nil { + return err + } + + if u.DefaultProjectID != 0 { + return err + } + + u.DefaultProjectID = p.ID + _, err = user.UpdateUser(s, u, false) + return err } func UpdateProject(s *xorm.Session, project *Project, auth web.Auth, updateProjectBackground bool) (err error) { diff --git a/pkg/user/user_create.go b/pkg/user/user_create.go index b51e94bb3..6f09ed66c 100644 --- a/pkg/user/user_create.go +++ b/pkg/user/user_create.go @@ -87,7 +87,7 @@ func CreateUser(s *xorm.Session, user *User) (newUser *User, err error) { return nil, err } - // Dont send a mail if no mailer is configured + // Don't send a mail if no mailer is configured if !config.MailerEnabled.GetBool() || user.Issuer != IssuerLocal { return newUserOut, err }