1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-04 01:18:20 +02:00

feat: enterprise service accounts (BE) (#2806)

https://linear.app/unleash/issue/2-537/back-end-for-service-accounts

Supersedes https://github.com/Unleash/unleash/pull/2731
This commit is contained in:
Nuno Góis 2023-01-03 15:15:32 +00:00 committed by GitHub
parent 093156f5f5
commit 28fbcf69ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 3 deletions

View File

@ -100,7 +100,7 @@ class UserStore implements IUserStore {
} }
buildSelectUser(q: IUserLookup): any { buildSelectUser(q: IUserLookup): any {
const query = this.activeUsers(); const query = this.activeAll();
if (q.id) { if (q.id) {
return query.where('id', q.id); return query.where('id', q.id);
} }
@ -113,8 +113,17 @@ class UserStore implements IUserStore {
throw new Error('Can only find users with id, username or email.'); throw new Error('Can only find users with id, username or email.');
} }
activeAll(): any {
return this.db(TABLE).where({
deleted_at: null,
});
}
activeUsers(): any { activeUsers(): any {
return this.db(TABLE).where('deleted_at', null); return this.db(TABLE).where({
deleted_at: null,
is_service: false,
});
} }
async hasUser(idQuery: IUserLookup): Promise<number | undefined> { async hasUser(idQuery: IUserLookup): Promise<number | undefined> {

View File

@ -0,0 +1,19 @@
exports.up = function (db, cb) {
db.runSql(
`
ALTER table users
ADD COLUMN IF NOT EXISTS is_service boolean DEFAULT false
`,
cb,
);
};
exports.down = function (db, cb) {
db.runSql(
`
ALTER table users
DROP COLUMN is_service
`,
cb,
);
};

View File

@ -41,7 +41,6 @@ process.nextTick(async () => {
responseTimeWithAppName: true, responseTimeWithAppName: true,
variantsPerEnvironment: true, variantsPerEnvironment: true,
maintenance: false, maintenance: false,
serviceAccounts: true,
}, },
}, },
authentication: { authentication: {