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';
3
3
import TimeZones from '../../core/TimeZones' ;
4
4
import { ObjectId } from 'mongodb' ;
5
5
import User from './User' ;
6
+ import DatabaseError from '../../errors/DatabaseError' ;
6
7
7
8
export default class Org extends Model {
9
+ protected readonly RESERVED_ORG_NAME = 'Scale8' ;
10
+
8
11
public getOrgEntityId ( ) : ObjectId {
9
12
return this . id ;
10
13
}
@@ -51,6 +54,9 @@ export default class Org extends Model {
51
54
if ( orgOwnerUser !== undefined ) {
52
55
this . _org_owner_user_id = orgOwnerUser . id ;
53
56
}
57
+ if ( name === this . RESERVED_ORG_NAME && ! orgOwnerUser . isAdmin ) {
58
+ throw new DatabaseError ( 'Protected org name used' ) ;
59
+ }
54
60
this . _name = name ;
55
61
this . _tz = tz ;
56
62
this . _manual_invoicing = manualInvoicing ;
@@ -65,7 +71,11 @@ export default class Org extends Model {
65
71
}
66
72
67
73
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
+ }
69
79
}
70
80
71
81
get tz ( ) : string {
You can’t perform that action at this time.
0 commit comments