diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index 603140715b..463716b5f7 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -49,14 +49,6 @@ export class MeController { this.userRepository = repositories.User; } - /** - * Return the logged-in user. - */ - @Get('/') - async getCurrentUser(req: AuthenticatedRequest): Promise { - return sanitizeUser(req.user); - } - /** * Update the logged-in user's settings, except password. */ diff --git a/packages/cli/test/integration/me.api.test.ts b/packages/cli/test/integration/me.api.test.ts index 4335b62fb5..9a2d2cd7c5 100644 --- a/packages/cli/test/integration/me.api.test.ts +++ b/packages/cli/test/integration/me.api.test.ts @@ -40,39 +40,6 @@ afterAll(async () => { }); 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 () => { const ownerShell = await testDb.createUserShell(globalOwnerRole); 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 () => { const member = await testDb.createUser({ globalRole: globalMemberRole }); const authMemberAgent = authAgent(member); @@ -433,39 +367,6 @@ describe('Owner', () => { 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 () => { const owner = await testDb.createUser({ globalRole: globalOwnerRole }); const authOwnerAgent = authAgent(owner); diff --git a/packages/cli/test/integration/shared/constants.ts b/packages/cli/test/integration/shared/constants.ts index b7850ab46a..c04c1e7c83 100644 --- a/packages/cli/test/integration/shared/constants.ts +++ b/packages/cli/test/integration/shared/constants.ts @@ -28,7 +28,6 @@ export const LOGGED_OUT_RESPONSE_BODY = { * Routes requiring a valid `n8n-auth` cookie for a user, either owner or member. */ export const ROUTES_REQUIRING_AUTHENTICATION: Readonly = [ - 'GET /me', 'PATCH /me', 'PATCH /me/password', 'POST /me/survey', diff --git a/packages/editor-ui/src/api/users.ts b/packages/editor-ui/src/api/users.ts index b876fd327a..d7cabf2cbf 100644 --- a/packages/editor-ui/src/api/users.ts +++ b/packages/editor-ui/src/api/users.ts @@ -5,16 +5,12 @@ import { IUserResponse, } from '@/Interface'; import { IDataObject } from 'n8n-workflow'; -import { makeRestApiRequest } from '@/utils'; +import { makeRestApiRequest } from '@/utils/apiUtils'; export function loginCurrentUser(context: IRestApiContext): Promise { return makeRestApiRequest(context, 'GET', '/login'); } -export function getCurrentUser(context: IRestApiContext): Promise { - return makeRestApiRequest(context, 'GET', '/me'); -} - export function login( context: IRestApiContext, params: { email: string; password: string }, diff --git a/packages/editor-ui/src/stores/users.ts b/packages/editor-ui/src/stores/users.ts index 93e8304e0f..d7b3e79cc6 100644 --- a/packages/editor-ui/src/stores/users.ts +++ b/packages/editor-ui/src/stores/users.ts @@ -1,7 +1,6 @@ import { changePassword, deleteUser, - getCurrentUser, getInviteLink, getUsers, inviteUsers, @@ -138,16 +137,6 @@ export const useUsersStore = defineStore(STORES.USERS, { } Vue.set(this.currentUser, 'personalizationAnswers', answers); }, - async getCurrentUser(): Promise { - const rootStore = useRootStore(); - const user = await getCurrentUser(rootStore.getRestApiContext); - if (user) { - this.addUsers([user]); - this.currentUserId = user.id; - } - - return user; - }, async loginWithCookie(): Promise { const rootStore = useRootStore(); const user = await loginCurrentUser(rootStore.getRestApiContext);