mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
refactor: remove unused my-sessions endpoint (#1691)
This commit is contained in:
parent
90b72f1162
commit
d7c450abf8
@ -61,25 +61,6 @@ test('should allow user to change password', async () => {
|
|||||||
expect(updated.passwordHash).toBeTruthy();
|
expect(updated.passwordHash).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should get my sessions', async () => {
|
|
||||||
const { request, base, sessionStore } = await getSetup();
|
|
||||||
|
|
||||||
sessionStore.insertSession({
|
|
||||||
sid: '123',
|
|
||||||
sess: { user: currentUser },
|
|
||||||
});
|
|
||||||
|
|
||||||
await request
|
|
||||||
.get(`${base}/api/admin/user/my-sessions`)
|
|
||||||
.expect(200)
|
|
||||||
.expect((res) => {
|
|
||||||
expect(res.body.length).toBe(1);
|
|
||||||
expect(res.body[0].sid).toBe('123');
|
|
||||||
expect(res.body[0].sess.user.id).toBe(currentUser.id);
|
|
||||||
expect(res.body[0].sess.user.email).toBe(currentUser.email);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should deny if password and confirmPassword are not equal', async () => {
|
test('should deny if password and confirmPassword are not equal', async () => {
|
||||||
expect.assertions(0);
|
expect.assertions(0);
|
||||||
const { request, base } = await getSetup();
|
const { request, base } = await getSetup();
|
||||||
|
@ -5,7 +5,6 @@ import { AccessService } from '../../services/access-service';
|
|||||||
import { IAuthType, IUnleashConfig } from '../../types/option';
|
import { IAuthType, IUnleashConfig } from '../../types/option';
|
||||||
import { IUnleashServices } from '../../types/services';
|
import { IUnleashServices } from '../../types/services';
|
||||||
import UserService from '../../services/user-service';
|
import UserService from '../../services/user-service';
|
||||||
import SessionService from '../../services/session-service';
|
|
||||||
import UserFeedbackService from '../../services/user-feedback-service';
|
import UserFeedbackService from '../../services/user-feedback-service';
|
||||||
import UserSplashService from '../../services/user-splash-service';
|
import UserSplashService from '../../services/user-splash-service';
|
||||||
import { ADMIN, NONE } from '../../types/permissions';
|
import { ADMIN, NONE } from '../../types/permissions';
|
||||||
@ -22,8 +21,6 @@ class UserController extends Controller {
|
|||||||
|
|
||||||
private userFeedbackService: UserFeedbackService;
|
private userFeedbackService: UserFeedbackService;
|
||||||
|
|
||||||
private sessionService: SessionService;
|
|
||||||
|
|
||||||
private userSplashService: UserSplashService;
|
private userSplashService: UserSplashService;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -31,14 +28,12 @@ class UserController extends Controller {
|
|||||||
{
|
{
|
||||||
accessService,
|
accessService,
|
||||||
userService,
|
userService,
|
||||||
sessionService,
|
|
||||||
userFeedbackService,
|
userFeedbackService,
|
||||||
userSplashService,
|
userSplashService,
|
||||||
}: Pick<
|
}: Pick<
|
||||||
IUnleashServices,
|
IUnleashServices,
|
||||||
| 'accessService'
|
| 'accessService'
|
||||||
| 'userService'
|
| 'userService'
|
||||||
| 'sessionService'
|
|
||||||
| 'userFeedbackService'
|
| 'userFeedbackService'
|
||||||
| 'userSplashService'
|
| 'userSplashService'
|
||||||
>,
|
>,
|
||||||
@ -46,13 +41,11 @@ class UserController extends Controller {
|
|||||||
super(config);
|
super(config);
|
||||||
this.accessService = accessService;
|
this.accessService = accessService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.sessionService = sessionService;
|
|
||||||
this.userFeedbackService = userFeedbackService;
|
this.userFeedbackService = userFeedbackService;
|
||||||
this.userSplashService = userSplashService;
|
this.userSplashService = userSplashService;
|
||||||
|
|
||||||
this.get('/', this.getUser);
|
this.get('/', this.getUser);
|
||||||
this.post('/change-password', this.updateUserPass, NONE);
|
this.post('/change-password', this.updateUserPass, NONE);
|
||||||
this.get('/my-sessions', this.mySessions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUser(req: IAuthRequest, res: Response): Promise<void> {
|
async getUser(req: IAuthRequest, res: Response): Promise<void> {
|
||||||
@ -89,12 +82,6 @@ class UserController extends Controller {
|
|||||||
res.status(400).end();
|
res.status(400).end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async mySessions(req: IAuthRequest, res: Response): Promise<void> {
|
|
||||||
const { user } = req;
|
|
||||||
const sessions = await this.sessionService.getSessionsForUser(user.id);
|
|
||||||
res.json(sessions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserController;
|
module.exports = UserController;
|
||||||
|
Loading…
Reference in New Issue
Block a user