Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit 092b7c7

Browse files
author
Leonardo Chaia
committed
fix: log out from docker hub
1 parent 0408e3d commit 092b7c7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/app/settings/registry-settings-modal/registry-settings-modal.component.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FormGroup } from '@angular/forms';
44
import { DockerHubService } from '../../docker-hub/docker-hub.service';
55
import { NotificationService } from '../../shared/notification.service';
66
import { RegistryService } from '../../registry/registry.service';
7-
import { Observable, throwError } from 'rxjs';
7+
import { Observable, throwError, of } from 'rxjs';
88
import { take, catchError } from 'rxjs/operators';
99
import { HttpErrorResponse } from '@angular/common/http';
1010
import { DockerRegistrySettings } from '../settings.model';
@@ -39,14 +39,17 @@ export class RegistrySettingsModalComponent implements OnInit {
3939
if (registrySettings.isDockerHub) {
4040
const username = registrySettings.username;
4141
const password = registrySettings.password;
42-
obs = this.dockerHub.logIn(username, password)
43-
.pipe(catchError((error: HttpErrorResponse) => {
44-
this.notification.open(error.error.detail || error.message, null, {
45-
panelClass: 'tim-bg-warn'
46-
});
47-
return throwError(error);
48-
}));
49-
42+
if (username) {
43+
obs = this.dockerHub.logIn(username, password)
44+
.pipe(catchError((error: HttpErrorResponse) => {
45+
this.notification.open(error.error.detail || error.message, null, {
46+
panelClass: 'tim-bg-warn'
47+
});
48+
return throwError(error);
49+
}));
50+
} else {
51+
obs = of(null);
52+
}
5053
} else {
5154
obs = this.registry.testRegistrySettings(registrySettings)
5255
.pipe(catchError((error: HttpErrorResponse) => {

0 commit comments

Comments
 (0)