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,
|
||||
ADMIN,
|
||||
} from '../types/permissions';
|
||||
import ApiUser from '../types/api-user';
|
||||
import { IUnleashConfig } from '../types/option';
|
||||
import { IUnleashStores } from '../types/stores';
|
||||
import User from '../types/user';
|
||||
|
@ -14,7 +14,6 @@ import { AccessService } from '../../services/access-service';
|
||||
import { IAuthRequest } from '../unleash-types';
|
||||
import User from '../../types/user';
|
||||
import { IUnleashConfig } from '../../types/option';
|
||||
import ApiUser from '../../types/api-user';
|
||||
|
||||
interface IServices {
|
||||
apiTokenService: ApiTokenService;
|
||||
@ -40,8 +39,8 @@ class ApiTokenController extends Controller {
|
||||
this.delete('/:token', this.deleteApiToken, DELETE_API_TOKEN);
|
||||
}
|
||||
|
||||
private async isTokenAdmin(user: User | ApiUser) {
|
||||
if (user instanceof ApiUser) {
|
||||
private async isTokenAdmin(user: User) {
|
||||
if (user.isAPI) {
|
||||
return user.permissions.includes(ADMIN);
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,9 @@ export class AccessService {
|
||||
}
|
||||
|
||||
async getPermissionsForUser(user: User): Promise<IUserPermission[]> {
|
||||
if (user.isAPI) {
|
||||
return [];
|
||||
}
|
||||
return this.store.getPermissionsForUser(user.id);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ export interface IUser {
|
||||
}
|
||||
|
||||
export default class User implements IUser {
|
||||
isAPI: boolean = false;
|
||||
|
||||
id: number;
|
||||
|
||||
name: string;
|
||||
|
Loading…
Reference in New Issue
Block a user