Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default (): any => {
},
chirpstack: {
apikey: process.env.CHIRPSTACK_API_KEY || "apikey",
hostname: process.env.CHIRPSTACK_HOSTNAME || "localhost",
port: process.env.CHIRPSTACK_PORT || 8080,
},
logLevels: process.env.LOG_LEVEL ? GetLogLevels(process.env.LOG_LEVEL) : GetLogLevels("debug"),
email: {
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/user-management/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AuthController {

// Login without proper roles
if (!(req.user instanceof User)) {
if (req.user == ErrorCodes.MissingRole) {
if (req.user === ErrorCodes.MissingRole) {
// Send back to frontend with an error
if (redirectTarget) {
return res.redirect(`${redirectTarget}?error=${ErrorCodes.MissingRole}`);
Expand All @@ -82,6 +82,9 @@ export class AuthController {
const { nameId, id } = req.user;
const jwt = await this.authService.issueJwt(nameId, id, true);
const baseUrl = redirectTarget ? redirectTarget : Configuration()["frontend"]["baseurl"];
if (!baseUrl.includes("applications")) {
return res.redirect(`${baseUrl}/applications?jwt=${jwt.accessToken}`);
}
return res.redirect(`${baseUrl}?jwt=${jwt.accessToken}`);
}

Expand Down
2 changes: 1 addition & 1 deletion src/entities/dto/list-all-entities.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export class ListAllEntitiesDto {
| "deviceModel"
| "devices"
| "dataTargets"
| "organizationName";
| "organizationName"
}
2 changes: 1 addition & 1 deletion src/services/chirpstack/chirpstack-gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export class ChirpstackGatewayService extends GenericChirpstackConfigurationServ
private getSortingForGateways(query: ListAllEntitiesDto) {
let orderBy = "gateway.id";

if (query.orderOn == null) {
if (!query.orderOn) {
return orderBy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MulticastGroupServiceClient } from "@chirpstack/chirpstack-api/api/mult

@Injectable()
export class GenericChirpstackConfigurationService {
baseUrlGRPC = `${process.env.CHIRPSTACK_HOSTNAME || "localhost"}:${process.env.CHIRPSTACK_PORT || "8080"}`;
baseUrlGRPC = `${configuration()["chirpstack"]["hostname"]}:${configuration()["chirpstack"]["port"]}`;

private readonly innerLogger = new Logger(GenericChirpstackConfigurationService.name);
protected applicationServiceClient = new ApplicationServiceClient(this.baseUrlGRPC, credentials.createInsecure());
Expand Down
2 changes: 1 addition & 1 deletion src/services/data-management/payload-decoder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class PayloadDecoderService {
organizationId: number | null | undefined
): Promise<ListAllPayloadDecoderResponseDto> {
const [result, total] = await this.payloadDecoderRepository.findAndCount({
where: organizationId ? { id: organizationId } : {},
where: organizationId ? { organization: {id: organizationId} } : {},
take: query.limit,
skip: query.offset,
order: this.getSorting(query),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { timestampToDate } from "@helpers/date.helper";
import { GetGatewayRequest, GetGatewayResponse } from "@chirpstack/chirpstack-api/api/gateway_pb";
import { GatewayServiceClient } from "@chirpstack/chirpstack-api/api/gateway_grpc_pb";
import { credentials } from "@grpc/grpc-js";
import configuration from "@config/configuration";

@Injectable()
export class LorawanDeviceDatabaseEnrichJob {
Expand All @@ -23,7 +24,7 @@ export class LorawanDeviceDatabaseEnrichJob {
@InjectRepository(Gateway)
private gatewayRepository: Repository<Gateway>
) {}
baseUrlGRPC = `${process.env.CHIRPSTACK_HOSTNAME || "localhost"}:${process.env.CHIRPSTACK_PORT || "8080"}`;
baseUrlGRPC = `${configuration()["chirpstack"]["hostname"]}:${configuration()["chirpstack"]["port"]}`;
private gatewayClient = new GatewayServiceClient(this.baseUrlGRPC, credentials.createInsecure());

private readonly logger = new Logger(LorawanDeviceDatabaseEnrichJob.name, { timestamp: true });
Expand Down