refactor(shared): rename Org to Instance
This commit is contained in:
@@ -22,7 +22,7 @@ var ErrEmailTaken = errors.New("email already registered")
|
||||
|
||||
// CreateUser hashes password and inserts the user. An empty password leaves the
|
||||
// hash empty, which is how OIDC users are stored.
|
||||
func CreateUser(ctx context.Context, db *mongo.Database, orgID, email, password, role, authSource string) (*models.User, error) {
|
||||
func CreateUser(ctx context.Context, db *mongo.Database, instanceID, email, password, role, authSource string) (*models.User, error) {
|
||||
var hash string
|
||||
if password != "" {
|
||||
b, err := bcrypt.GenerateFromPassword([]byte(password), BcryptCost)
|
||||
@@ -31,13 +31,13 @@ func CreateUser(ctx context.Context, db *mongo.Database, orgID, email, password,
|
||||
}
|
||||
hash = string(b)
|
||||
}
|
||||
return CreateUserWithHash(ctx, db, orgID, email, hash, role, authSource)
|
||||
return CreateUserWithHash(ctx, db, instanceID, email, hash, role, authSource)
|
||||
}
|
||||
|
||||
// CreateUserWithHash inserts a user whose password was already hashed
|
||||
// elsewhere. sitesvc hashes at signup and only holds the hash by the time the
|
||||
// verification link is opened.
|
||||
func CreateUserWithHash(ctx context.Context, db *mongo.Database, orgID, email, passwordHash, role, authSource string) (*models.User, error) {
|
||||
func CreateUserWithHash(ctx context.Context, db *mongo.Database, instanceID, email, passwordHash, role, authSource string) (*models.User, error) {
|
||||
email = strings.ToLower(strings.TrimSpace(email))
|
||||
if email == "" {
|
||||
return nil, fmt.Errorf("email required")
|
||||
@@ -48,7 +48,7 @@ func CreateUserWithHash(ctx context.Context, db *mongo.Database, orgID, email, p
|
||||
|
||||
u := &models.User{
|
||||
UserID: uuid.NewString(),
|
||||
OrgID: orgID,
|
||||
InstanceID: instanceID,
|
||||
Email: email,
|
||||
PasswordHash: passwordHash,
|
||||
Role: role,
|
||||
|
||||
Reference in New Issue
Block a user