mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Delete unused GET /me endpoint (no-changelog) (#5498)
This commit is contained in:
committed by
GitHub
parent
d143f3f2ec
commit
12104bc4a3
@@ -49,14 +49,6 @@ export class MeController {
|
|||||||
this.userRepository = repositories.User;
|
this.userRepository = repositories.User;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the logged-in user.
|
|
||||||
*/
|
|
||||||
@Get('/')
|
|
||||||
async getCurrentUser(req: AuthenticatedRequest): Promise<PublicUser> {
|
|
||||||
return sanitizeUser(req.user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the logged-in user's settings, except password.
|
* Update the logged-in user's settings, except password.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,39 +40,6 @@ afterAll(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Owner shell', () => {
|
describe('Owner shell', () => {
|
||||||
test('GET /me should return sanitized owner shell', async () => {
|
|
||||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
|
||||||
|
|
||||||
const response = await authAgent(ownerShell).get('/me');
|
|
||||||
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const {
|
|
||||||
id,
|
|
||||||
email,
|
|
||||||
firstName,
|
|
||||||
lastName,
|
|
||||||
personalizationAnswers,
|
|
||||||
globalRole,
|
|
||||||
password,
|
|
||||||
resetPasswordToken,
|
|
||||||
isPending,
|
|
||||||
apiKey,
|
|
||||||
} = response.body.data;
|
|
||||||
|
|
||||||
expect(validator.isUUID(id)).toBe(true);
|
|
||||||
expect(email).toBeNull();
|
|
||||||
expect(firstName).toBeNull();
|
|
||||||
expect(lastName).toBeNull();
|
|
||||||
expect(personalizationAnswers).toBeNull();
|
|
||||||
expect(password).toBeUndefined();
|
|
||||||
expect(resetPasswordToken).toBeUndefined();
|
|
||||||
expect(isPending).toBe(true);
|
|
||||||
expect(globalRole.name).toBe('owner');
|
|
||||||
expect(globalRole.scope).toBe('global');
|
|
||||||
expect(apiKey).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('PATCH /me should succeed with valid inputs', async () => {
|
test('PATCH /me should succeed with valid inputs', async () => {
|
||||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||||
const authOwnerShellAgent = authAgent(ownerShell);
|
const authOwnerShellAgent = authAgent(ownerShell);
|
||||||
@@ -234,39 +201,6 @@ describe('Member', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GET /me should return sanitized member', async () => {
|
|
||||||
const member = await testDb.createUser({ globalRole: globalMemberRole });
|
|
||||||
|
|
||||||
const response = await authAgent(member).get('/me');
|
|
||||||
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const {
|
|
||||||
id,
|
|
||||||
email,
|
|
||||||
firstName,
|
|
||||||
lastName,
|
|
||||||
personalizationAnswers,
|
|
||||||
globalRole,
|
|
||||||
password,
|
|
||||||
resetPasswordToken,
|
|
||||||
isPending,
|
|
||||||
apiKey,
|
|
||||||
} = response.body.data;
|
|
||||||
|
|
||||||
expect(validator.isUUID(id)).toBe(true);
|
|
||||||
expect(email).toBe(member.email);
|
|
||||||
expect(firstName).toBe(member.firstName);
|
|
||||||
expect(lastName).toBe(member.lastName);
|
|
||||||
expect(personalizationAnswers).toBeNull();
|
|
||||||
expect(password).toBeUndefined();
|
|
||||||
expect(resetPasswordToken).toBeUndefined();
|
|
||||||
expect(isPending).toBe(false);
|
|
||||||
expect(globalRole.name).toBe('member');
|
|
||||||
expect(globalRole.scope).toBe('global');
|
|
||||||
expect(apiKey).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('PATCH /me should succeed with valid inputs', async () => {
|
test('PATCH /me should succeed with valid inputs', async () => {
|
||||||
const member = await testDb.createUser({ globalRole: globalMemberRole });
|
const member = await testDb.createUser({ globalRole: globalMemberRole });
|
||||||
const authMemberAgent = authAgent(member);
|
const authMemberAgent = authAgent(member);
|
||||||
@@ -433,39 +367,6 @@ describe('Owner', () => {
|
|||||||
config.set('userManagement.isInstanceOwnerSetUp', true);
|
config.set('userManagement.isInstanceOwnerSetUp', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GET /me should return sanitized owner', async () => {
|
|
||||||
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
|
|
||||||
|
|
||||||
const response = await authAgent(owner).get('/me');
|
|
||||||
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const {
|
|
||||||
id,
|
|
||||||
email,
|
|
||||||
firstName,
|
|
||||||
lastName,
|
|
||||||
personalizationAnswers,
|
|
||||||
globalRole,
|
|
||||||
password,
|
|
||||||
resetPasswordToken,
|
|
||||||
isPending,
|
|
||||||
apiKey,
|
|
||||||
} = response.body.data;
|
|
||||||
|
|
||||||
expect(validator.isUUID(id)).toBe(true);
|
|
||||||
expect(email).toBe(owner.email);
|
|
||||||
expect(firstName).toBe(owner.firstName);
|
|
||||||
expect(lastName).toBe(owner.lastName);
|
|
||||||
expect(personalizationAnswers).toBeNull();
|
|
||||||
expect(password).toBeUndefined();
|
|
||||||
expect(resetPasswordToken).toBeUndefined();
|
|
||||||
expect(isPending).toBe(false);
|
|
||||||
expect(globalRole.name).toBe('owner');
|
|
||||||
expect(globalRole.scope).toBe('global');
|
|
||||||
expect(apiKey).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('PATCH /me should succeed with valid inputs', async () => {
|
test('PATCH /me should succeed with valid inputs', async () => {
|
||||||
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
|
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
|
||||||
const authOwnerAgent = authAgent(owner);
|
const authOwnerAgent = authAgent(owner);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export const LOGGED_OUT_RESPONSE_BODY = {
|
|||||||
* Routes requiring a valid `n8n-auth` cookie for a user, either owner or member.
|
* Routes requiring a valid `n8n-auth` cookie for a user, either owner or member.
|
||||||
*/
|
*/
|
||||||
export const ROUTES_REQUIRING_AUTHENTICATION: Readonly<string[]> = [
|
export const ROUTES_REQUIRING_AUTHENTICATION: Readonly<string[]> = [
|
||||||
'GET /me',
|
|
||||||
'PATCH /me',
|
'PATCH /me',
|
||||||
'PATCH /me/password',
|
'PATCH /me/password',
|
||||||
'POST /me/survey',
|
'POST /me/survey',
|
||||||
|
|||||||
@@ -5,16 +5,12 @@ import {
|
|||||||
IUserResponse,
|
IUserResponse,
|
||||||
} from '@/Interface';
|
} from '@/Interface';
|
||||||
import { IDataObject } from 'n8n-workflow';
|
import { IDataObject } from 'n8n-workflow';
|
||||||
import { makeRestApiRequest } from '@/utils';
|
import { makeRestApiRequest } from '@/utils/apiUtils';
|
||||||
|
|
||||||
export function loginCurrentUser(context: IRestApiContext): Promise<IUserResponse | null> {
|
export function loginCurrentUser(context: IRestApiContext): Promise<IUserResponse | null> {
|
||||||
return makeRestApiRequest(context, 'GET', '/login');
|
return makeRestApiRequest(context, 'GET', '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentUser(context: IRestApiContext): Promise<IUserResponse | null> {
|
|
||||||
return makeRestApiRequest(context, 'GET', '/me');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function login(
|
export function login(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
params: { email: string; password: string },
|
params: { email: string; password: string },
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
changePassword,
|
changePassword,
|
||||||
deleteUser,
|
deleteUser,
|
||||||
getCurrentUser,
|
|
||||||
getInviteLink,
|
getInviteLink,
|
||||||
getUsers,
|
getUsers,
|
||||||
inviteUsers,
|
inviteUsers,
|
||||||
@@ -138,16 +137,6 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||||||
}
|
}
|
||||||
Vue.set(this.currentUser, 'personalizationAnswers', answers);
|
Vue.set(this.currentUser, 'personalizationAnswers', answers);
|
||||||
},
|
},
|
||||||
async getCurrentUser(): Promise<IUserResponse | null> {
|
|
||||||
const rootStore = useRootStore();
|
|
||||||
const user = await getCurrentUser(rootStore.getRestApiContext);
|
|
||||||
if (user) {
|
|
||||||
this.addUsers([user]);
|
|
||||||
this.currentUserId = user.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return user;
|
|
||||||
},
|
|
||||||
async loginWithCookie(): Promise<void> {
|
async loginWithCookie(): Promise<void> {
|
||||||
const rootStore = useRootStore();
|
const rootStore = useRootStore();
|
||||||
const user = await loginCurrentUser(rootStore.getRestApiContext);
|
const user = await loginCurrentUser(rootStore.getRestApiContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user