mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 18:41:21 +00:00
fix(telemetry): added back email for telemetry when using service token
This commit is contained in:
@@ -1,10 +1,32 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
import { TableName, TUsers } from "@app/db/schemas";
|
||||
import { DatabaseError } from "@app/lib/errors";
|
||||
import { ormify, selectAllTableCols } from "@app/lib/knex";
|
||||
|
||||
export type TServiceTokenDALFactory = ReturnType<typeof serviceTokenDALFactory>;
|
||||
|
||||
export const serviceTokenDALFactory = (db: TDbClient) => {
|
||||
const stOrm = ormify(db, TableName.ServiceToken);
|
||||
return stOrm;
|
||||
|
||||
const findById = async (id: string, tx?: Knex) => {
|
||||
try {
|
||||
const doc = await (tx || db)(TableName.ServiceToken)
|
||||
.leftJoin<TUsers>(
|
||||
TableName.Users,
|
||||
`${TableName.Users}.id`,
|
||||
db.raw(`${TableName.ServiceToken}."createdBy"::uuid`)
|
||||
)
|
||||
.where(`${TableName.ServiceToken}.id`, id)
|
||||
.select(selectAllTableCols(TableName.ServiceToken))
|
||||
.select(db.ref("email").withSchema(TableName.Users).as("createdByEmail"))
|
||||
.first();
|
||||
return doc;
|
||||
} catch (err) {
|
||||
throw new DatabaseError({ error: err, name: "FindById" });
|
||||
}
|
||||
};
|
||||
|
||||
return { ...stOrm, findById };
|
||||
};
|
||||
|
||||
@@ -142,7 +142,7 @@ export const serviceTokenServiceFactory = ({
|
||||
const updatedToken = await serviceTokenDAL.updateById(serviceToken.id, {
|
||||
lastUsed: new Date()
|
||||
});
|
||||
return updatedToken;
|
||||
return { ...serviceToken, lastUsed: updatedToken.lastUsed };
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user