mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
fix: regular users are not API users
This commit is contained in:
parent
85a544bbd6
commit
0bed8f605e
@ -5,7 +5,6 @@ import {
|
|||||||
DELETE_FEATURE,
|
DELETE_FEATURE,
|
||||||
ADMIN,
|
ADMIN,
|
||||||
} from '../types/permissions';
|
} from '../types/permissions';
|
||||||
import ApiUser from '../types/api-user';
|
|
||||||
import { IUnleashConfig } from '../types/option';
|
import { IUnleashConfig } from '../types/option';
|
||||||
import { IUnleashStores } from '../types/stores';
|
import { IUnleashStores } from '../types/stores';
|
||||||
import User from '../types/user';
|
import User from '../types/user';
|
||||||
|
@ -14,7 +14,6 @@ import { AccessService } from '../../services/access-service';
|
|||||||
import { IAuthRequest } from '../unleash-types';
|
import { IAuthRequest } from '../unleash-types';
|
||||||
import User from '../../types/user';
|
import User from '../../types/user';
|
||||||
import { IUnleashConfig } from '../../types/option';
|
import { IUnleashConfig } from '../../types/option';
|
||||||
import ApiUser from '../../types/api-user';
|
|
||||||
|
|
||||||
interface IServices {
|
interface IServices {
|
||||||
apiTokenService: ApiTokenService;
|
apiTokenService: ApiTokenService;
|
||||||
@ -40,8 +39,8 @@ class ApiTokenController extends Controller {
|
|||||||
this.delete('/:token', this.deleteApiToken, DELETE_API_TOKEN);
|
this.delete('/:token', this.deleteApiToken, DELETE_API_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async isTokenAdmin(user: User | ApiUser) {
|
private async isTokenAdmin(user: User) {
|
||||||
if (user instanceof ApiUser) {
|
if (user.isAPI) {
|
||||||
return user.permissions.includes(ADMIN);
|
return user.permissions.includes(ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,9 @@ export class AccessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getPermissionsForUser(user: User): Promise<IUserPermission[]> {
|
async getPermissionsForUser(user: User): Promise<IUserPermission[]> {
|
||||||
|
if (user.isAPI) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return this.store.getPermissionsForUser(user.id);
|
return this.store.getPermissionsForUser(user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ export interface IUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class User implements IUser {
|
export default class User implements IUser {
|
||||||
|
isAPI: boolean = false;
|
||||||
|
|
||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user