fase(9): auth module with casl rbac and session management
This commit is contained in:
33
dist/modules/auth/domain/entities/Organization.js
vendored
Normal file
33
dist/modules/auth/domain/entities/Organization.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Organization = void 0;
|
||||
const AggregateRoot_1 = require("../../../../shared/domain/AggregateRoot");
|
||||
const UniqueId_1 = require("../../../../shared/domain/UniqueId");
|
||||
const OrgCreated_1 = require("../events/OrgCreated");
|
||||
class Organization extends AggregateRoot_1.AggregateRoot {
|
||||
static create(props, id) {
|
||||
const orgId = id ?? UniqueId_1.UniqueId.create();
|
||||
const org = new Organization({
|
||||
...props,
|
||||
createdAt: new Date(),
|
||||
}, orgId);
|
||||
org.addDomainEvent(new OrgCreated_1.OrgCreated(orgId.toString(), {
|
||||
name: props.name,
|
||||
slug: props.slug,
|
||||
}));
|
||||
return org;
|
||||
}
|
||||
static reconstitute(props, id) {
|
||||
return new Organization(props, id);
|
||||
}
|
||||
static slugify(name) {
|
||||
return name
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-|-$/g, '');
|
||||
}
|
||||
get name() { return this.props.name; }
|
||||
get slug() { return this.props.slug; }
|
||||
get createdAt() { return this.props.createdAt; }
|
||||
}
|
||||
exports.Organization = Organization;
|
||||
Reference in New Issue
Block a user