feat: add folder uploads and archives with simpler account and plan forms
This commit is contained in:
1 parent
9afd7d0067
commit
faaa614cee
41 files changed
+1027
-71
No files matched your search
@@ -1971,7 +1971,7 @@ func (s *Store) CreatePlan(ctx context.Context, input NewPlan) (uint64, error) {
|
||||
}
|
||||
|
||||
func (s *Store) ListTenants(ctx context.Context) ([]TenantSummary, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT t.id,t.slug,t.name,IF(t.status='active' AND COUNT(DISTINCT IF(u.role='tenant' AND u.status='active',u.id,NULL))>0,'active','suspended'),t.lifecycle_state,p.name,COUNT(DISTINCT IF(u.role='tenant',u.id,NULL)),COUNT(DISTINCT pr.id),t.expires_at,t.grace_until,t.purge_after,t.backup_purge_after,t.created_at FROM tenants t JOIN plans p ON p.id=t.plan_id LEFT JOIN users u ON u.tenant_id=t.id LEFT JOIN projects pr ON pr.owner_tenant_id=t.id WHERE t.resource_namespace=FALSE AND t.deleted_at IS NULL GROUP BY t.id ORDER BY t.id DESC`)
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT t.id,t.slug,t.name,IF(t.status='active' AND COUNT(DISTINCT IF(u.role='tenant' AND u.status='active',u.id,NULL))>0,'active','suspended'),t.lifecycle_state,p.name,COUNT(DISTINCT IF(u.role='tenant',u.id,NULL)),COUNT(DISTINCT pr.id),t.expires_at,t.grace_until,t.purge_after,t.backup_purge_after,t.created_at,COALESCE(MAX(IF(u.role='tenant',u.login_name,NULL)),'') FROM tenants t JOIN plans p ON p.id=t.plan_id LEFT JOIN users u ON u.tenant_id=t.id LEFT JOIN projects pr ON pr.owner_tenant_id=t.id WHERE t.resource_namespace=FALSE AND t.deleted_at IS NULL GROUP BY t.id ORDER BY t.id DESC`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1980,7 +1980,7 @@ func (s *Store) ListTenants(ctx context.Context) ([]TenantSummary, error) {
|
||||
for rows.Next() {
|
||||
var item TenantSummary
|
||||
var expires, grace, purge, backupPurge sql.NullTime
|
||||
if err := rows.Scan(&item.ID, &item.Slug, &item.Name, &item.Status, &item.LifecycleState, &item.PlanName, &item.UserCount, &item.ProjectCount, &expires, &grace, &purge, &backupPurge, &item.CreatedAt); err != nil {
|
||||
if err := rows.Scan(&item.ID, &item.Slug, &item.Name, &item.Status, &item.LifecycleState, &item.PlanName, &item.UserCount, &item.ProjectCount, &expires, &grace, &purge, &backupPurge, &item.CreatedAt, &item.LoginName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if expires.Valid {
|
||||
@@ -2283,6 +2283,10 @@ func (s *Store) AdminActivities(ctx context.Context, limit int) ([]AdminActivity
|
||||
}
|
||||
|
||||
func (s *Store) CreateTenant(ctx context.Context, input NewTenant) (uint64, error) {
|
||||
loginName := strings.ToLower(strings.TrimSpace(input.LoginName))
|
||||
if loginName == "" {
|
||||
loginName = strings.ToLower(input.Email)
|
||||
}
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(input.Password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -2305,7 +2309,7 @@ func (s *Store) CreateTenant(ctx context.Context, input NewTenant) (uint64, erro
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if _, err = tx.ExecContext(ctx, "INSERT INTO users(tenant_id,login_name,email,display_name,password_hash,role) VALUES (?,?,?,?,?,'tenant')", tenantID, strings.ToLower(input.Email), strings.ToLower(input.Email), input.DisplayName, string(hash)); err != nil {
|
||||
if _, err = tx.ExecContext(ctx, "INSERT INTO users(tenant_id,login_name,email,display_name,password_hash,role) VALUES (?,?,?,?,?,'tenant')", tenantID, loginName, strings.ToLower(input.Email), input.DisplayName, string(hash)); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if err = tx.Commit(); err != nil {
|
||||
|
||||
Reference in new issue
Block a user