Skip to content

Commit

Permalink
fixed typo and added check if token is not provided for update passwo…
Browse files Browse the repository at this point in the history
…rd (#697)

* fixed typo and added check if token is not provided for update password
  • Loading branch information
ygrik authored Jun 11, 2020
1 parent 6dbfb50 commit 2a0a69d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/defaultAuthenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export class DefaultAuthenticator implements IAuthenticator {
return accessToken;
}

throw new Error(`Access token format is not valid. Please use "Bearer" or "SharedAccessSignature".`);
accessToken = this.parseSharedAccessSignature(token);

if (!accessToken) {
throw new Error(`Access token format is not valid. Please use "Bearer" or "SharedAccessSignature".`);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ConfirmPassword {
}

try {
this.token = this.usersService.getTokenFromTiketParams(queryParams);
this.token = this.usersService.getTokenFromTicketParams(queryParams);
this.userId = this.usersService.getUserIdFromParams(queryParams);

if (!this.userId) {
Expand Down
9 changes: 6 additions & 3 deletions src/services/usersService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class UsersService {
}
}

public getTokenFromTiketParams(parameters: URLSearchParams): string {
public getTokenFromTicketParams(parameters: URLSearchParams): string {
const ticket = parameters.get("ticket");
const ticketId = parameters.get("ticketid");
const token = `Ticket id="${ticketId}",ticket="${ticket}"`;
Expand All @@ -82,8 +82,11 @@ export class UsersService {
}

public async updatePassword(userId: string, newPassword: string, token: string): Promise<void> {
const heasers = [{ name: "Authorization", value: token }];
await this.mapiClient.patch(userId, heasers, { password: newPassword });
const headers = []
if (token) {
headers.push({ name: "Authorization", value: token });
}
await this.mapiClient.patch(userId, headers, { password: newPassword });
}

/**
Expand Down

0 comments on commit 2a0a69d

Please sign in to comment.