Skip to content

Commit

Permalink
Handle error at removing Device Auth token
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
  • Loading branch information
RomanNikitenko committed Oct 25, 2023
1 parent 6e2d799 commit e74d10e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code/extensions/che-api/src/impl/github-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class GithubServiceImpl implements GithubService {
const deviceAuthSecrets = await this.k8sService.getSecret(DEVICE_AUTHENTICATION_LABEL_SELECTOR);
if (deviceAuthSecrets.length < 1) {
this.logger.warn('Github Service: device-authentication secret not found');
return;
throw new Error('device-authentication secret not found');
}

for (const secret of deviceAuthSecrets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ export class DeviceAuthentication {
}

async removeDeviceAuthToken(): Promise<void> {
return this.githubService.removeDeviceAuthToken();
try {
await this.githubService.removeDeviceAuthToken();
const message = 'The token was deleted successfully. Some operations may require Github Sign Out => Sign In to use another token.'
vscode.window.showInformationMessage(message);
} catch (error) {
const message = `Can not remove Device Authentication token: ${error.message}`;
vscode.window.showErrorMessage(message);
}

}

private async onTokenGenerated(scopes: string): Promise<void> {
Expand Down

0 comments on commit e74d10e

Please sign in to comment.