Skip to content

Commit

Permalink
fix(login-form): keep user on same page after login (DEV-1158) (#788)
Browse files Browse the repository at this point in the history
* fix(login-form): keep user on same page after login

* chore(archive): remove commented code
  • Loading branch information
mdelez committed Aug 4, 2022
1 parent db40310 commit 9ec6870
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/app/main/action/login-form/login-form.component.ts
Expand Up @@ -8,6 +8,7 @@ import { AuthenticationService } from '../../services/authentication.service';
import { ComponentCommunicationEventService, EmitEvent, Events } from '../../services/component-communication-event.service';
import { DatadogRumService } from '../../services/datadog-rum.service';
import { Session, SessionService } from '../../services/session.service';
import { Location } from '@angular/common';

@Component({
selector: 'app-login-form',
Expand Down Expand Up @@ -103,6 +104,7 @@ export class LoginFormComponent implements OnInit, AfterViewInit {
private _session: SessionService,
private _route: ActivatedRoute,
private _router: Router,
private _location: Location
) {
this.returnUrl = this._route.snapshot.queryParams['returnUrl'];
}
Expand Down Expand Up @@ -158,12 +160,11 @@ export class LoginFormComponent implements OnInit, AfterViewInit {
this.session = this._session.getSession();

this._componentCommsService.emit(new EmitEvent(Events.loginSuccess, true));

// if user hit a page that requires to be logged in, they will have a returnUrl in the url
this.returnUrl = this._route.snapshot.queryParams['returnUrl'];
if (this.returnUrl) {
this._router.navigate([this.returnUrl]);
} else if (!this._route.snapshot.url.length || (this._route.snapshot.url.length && this._route.snapshot.url[0].path === 'login')) { // if user is on "/" or "/login"
} else if (!this._location.path() || (this._route.snapshot.url.length && this._route.snapshot.url[0].path === 'login')) { // if user is on "/" or "/login"
const username = this.session.user.name;
this._dspApiConnection.admin.usersEndpoint.getUserByUsername(username).subscribe(
(userResponse: ApiResponseData<UserResponse>) => {
Expand Down
Expand Up @@ -34,15 +34,6 @@
</div>
</div>
</div>
<!-- <button class="download" mat-button (click)="downloadArchive(src.fileValue.fileUrl)" [disabled]="failedToLoad">
<mat-icon>
file_download
</mat-icon>
Click to download
</button>
<button mat-button matTooltip="Replace archive file" (click)="openReplaceFileDialog()">
<mat-icon>cloud_upload</mat-icon>
</button> -->
</div>
<div *ngIf="!src || !src.fileValue.fileUrl">
No valid file url found for this resource.
Expand Down

0 comments on commit 9ec6870

Please sign in to comment.