feat(api/private/me): include authProvider in UserInfo

This information is supposed to be used by the frontend
to identify the login method that was used.

The used login method is saved as a string into the session data
and extracted via a new SessionAuthProvider decorator.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-01-30 21:54:30 +01:00
parent 3f8e3b0589
commit d6ea4d29fe
7 changed files with 71 additions and 8 deletions

View file

@ -8,7 +8,7 @@ import request from 'supertest';
import { NotInDBError } from '../../src/errors/errors';
import { Note } from '../../src/notes/note.entity';
import { FullUserInfoDto } from '../../src/users/user-info.dto';
import { UserLoginInfoDto } from '../../src/users/user-info.dto';
import { User } from '../../src/users/user.entity';
import { TestSetup, TestSetupBuilder } from '../test-setup';
@ -50,12 +50,12 @@ describe('Me', () => {
});
it('GET /me', async () => {
const userInfo = testSetup.userService.toFullUserDto(user);
const userInfo = testSetup.userService.toUserLoginInfoDto(user, 'local');
const response = await agent
.get('/api/private/me')
.expect('Content-Type', /json/)
.expect(200);
const gotUser = response.body as FullUserInfoDto;
const gotUser = response.body as UserLoginInfoDto;
expect(gotUser).toEqual(userInfo);
});

View file

@ -55,6 +55,7 @@ describe('Register and Login', () => {
const profile = await session.get('/api/private/me').expect(200);
expect(profile.body.username).toEqual(USERNAME);
expect(profile.body.displayName).toEqual(DISPLAYNAME);
expect(profile.body.authProvider).toEqual('local');
// logout again
await session.delete('/api/private/auth/logout').expect(204);