This commit is contained in:
Simon Larsen 2023-09-01 18:46:35 +05:30
parent c3d378d20e
commit 269877469e
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
2 changed files with 26 additions and 22 deletions

View File

@ -41,7 +41,8 @@ export default class ResellerPlanAPI extends BaseAPI<
next: NextFunction
) => {
try {
const resellerId: string | undefined = req.params['resellerId'];
const resellerId: string | undefined =
req.params['resellerId'];
if (!resellerId) {
throw new Error('Invalid reseller id.');
@ -60,7 +61,7 @@ export default class ResellerPlanAPI extends BaseAPI<
const action: string = req.body.action;
if(!action){
if (!action) {
throw new BadDataException('Invalid action.');
}
@ -72,24 +73,25 @@ export default class ResellerPlanAPI extends BaseAPI<
// check reseller Plan.
const resellerPlan: ResellerPlan | null = await ResellerPlanService.findOneBy({
query: {
planId: resellerPlanId,
},
select: {
_id: true,
planId: true,
reseller: {
resellerId: true,
const resellerPlan: ResellerPlan | null =
await ResellerPlanService.findOneBy({
query: {
planId: resellerPlanId,
},
teamMemberLimit: true,
monitorLimit: true,
planType: true,
},
props: {
isRoot: true,
},
});
select: {
_id: true,
planId: true,
reseller: {
resellerId: true,
},
teamMemberLimit: true,
monitorLimit: true,
planType: true,
},
props: {
isRoot: true,
},
});
if (!resellerPlan) {
throw new BadDataException('Invalid reseller plan id.');
@ -104,11 +106,13 @@ export default class ResellerPlanAPI extends BaseAPI<
const licenseKey: string | undefined = req.body.uuid;
if(!licenseKey){
if (!licenseKey) {
throw new BadDataException('Invalid license key.');
}
const userEmail: Email = new Email(req.body.activation_email);
const userEmail: Email = new Email(
req.body.activation_email
);
if (action === 'activate') {
// generate a coupon code. Billing is handled by the reseller so OneUptime will have 100% discount on its plans.

View File

@ -17,7 +17,7 @@ export default class BearerTokenAuthorization {
req = req as OneUptimeRequest;
if (req.headers['authorization'] || req.headers['Authorization']) {
let token: string | undefined | Array<string> =
let token: string | undefined | Array<string> =
req.headers['authorization'] || req.headers['Authorization'];
if (token) {
token = token.toString().replace('Bearer ', '');