This repository was archived by the owner on Feb 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ import Field from '../decorators/Field';
33import TimeZones from '../../core/TimeZones' ;
44import { ObjectId } from 'mongodb' ;
55import User from './User' ;
6+ import DatabaseError from '../../errors/DatabaseError' ;
67
78export default class Org extends Model {
9+ protected readonly RESERVED_ORG_NAME = 'Scale8' ;
10+
811 public getOrgEntityId ( ) : ObjectId {
912 return this . id ;
1013 }
@@ -51,6 +54,9 @@ export default class Org extends Model {
5154 if ( orgOwnerUser !== undefined ) {
5255 this . _org_owner_user_id = orgOwnerUser . id ;
5356 }
57+ if ( name === this . RESERVED_ORG_NAME && ! orgOwnerUser . isAdmin ) {
58+ throw new DatabaseError ( 'Protected org name used' ) ;
59+ }
5460 this . _name = name ;
5561 this . _tz = tz ;
5662 this . _manual_invoicing = manualInvoicing ;
@@ -65,7 +71,11 @@ export default class Org extends Model {
6571 }
6672
6773 set name ( value : string ) {
68- this . _name = value ;
74+ if ( value === this . RESERVED_ORG_NAME ) {
75+ throw new DatabaseError ( 'Protected org name used' ) ;
76+ } else {
77+ this . _name = value ;
78+ }
6979 }
7080
7181 get tz ( ) : string {
You can’t perform that action at this time.
0 commit comments