1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-17 01:17:29 +02:00

fix: reset-token-service should use unleashUrl

This commit is contained in:
Christopher Kolstad 2021-05-07 10:38:41 +02:00
parent 5565dd8c4b
commit 0086580130
2 changed files with 12 additions and 5 deletions

View File

@ -36,7 +36,7 @@ export default class ResetTokenService {
) {
this.store = stores.resetTokenStore;
this.logger = getLogger('/services/reset-token-service.ts');
this.unleashBase = new URL(server.baseUriPath, server.unleashUrl);
this.unleashBase = new URL(server.unleashUrl);
}
async useAccessToken(token: IResetQuery): Promise<boolean> {
@ -100,12 +100,12 @@ export default class ResetTokenService {
forUser: number,
creator: string,
): Promise<URL> {
const path = '/#/reset-password';
const path = '/reset-password';
return this.createResetUrl(forUser, creator, path);
}
async createNewUserUrl(forUser: number, creator: string): Promise<URL> {
const path = '/#/new-user';
const path = '/new-user';
return this.createResetUrl(forUser, creator, path);
}

View File

@ -59,7 +59,10 @@ test.serial('Should create a reset link', async t => {
adminUser,
);
t.true(url.toString().indexOf('/reset-password') > 0);
t.is(
url.toString().substring(0, url.toString().indexOf('=')),
`${config.server.unleashUrl}/reset-password?token`,
);
});
test.serial('Should create a welcome link', async t => {
@ -67,7 +70,11 @@ test.serial('Should create a welcome link', async t => {
userIdToCreateResetFor,
adminUser.username,
);
t.true(url.toString().indexOf('/new-user') > 0);
const urlS = url.toString();
t.is(
urlS.substring(0, urlS.indexOf('=')),
`${config.server.unleashUrl}/new-user?token`,
);
});
test.serial('Tokens should be one-time only', async t => {