mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Changed method name.
This commit is contained in:
@@ -249,28 +249,28 @@ describe('AuthService test', () => {
|
|||||||
|
|
||||||
it ('should set redirect url to previous page', () => {
|
it ('should set redirect url to previous page', () => {
|
||||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||||
authService.redirectToPreviousUrl(true);
|
authService.redirectAfterLoginSuccess(true);
|
||||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/collection/123']);
|
expect(routerStub.navigate).toHaveBeenCalledWith(['/collection/123']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('should set redirect url to current page', () => {
|
it ('should set redirect url to current page', () => {
|
||||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||||
authService.redirectToPreviousUrl(false);
|
authService.redirectAfterLoginSuccess(false);
|
||||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/home']);
|
expect(routerStub.navigate).toHaveBeenCalledWith(['/home']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('should redirect to / and not to /login', () => {
|
it ('should redirect to / and not to /login', () => {
|
||||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['/login', '/login']));
|
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['/login', '/login']));
|
||||||
authService.redirectToPreviousUrl(true);
|
authService.redirectAfterLoginSuccess(true);
|
||||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('should redirect to / when no redirect url is found', () => {
|
it ('should redirect to / when no redirect url is found', () => {
|
||||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['']));
|
spyOn(routeServiceMock, 'getHistory').and.returnValue(of(['']));
|
||||||
authService.redirectToPreviousUrl(true);
|
authService.redirectAfterLoginSuccess(true);
|
||||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
||||||
});
|
});
|
||||||
|
@@ -339,7 +339,7 @@ export class AuthService {
|
|||||||
/**
|
/**
|
||||||
* Redirect to the route navigated before the login
|
* Redirect to the route navigated before the login
|
||||||
*/
|
*/
|
||||||
public redirectToPreviousUrl(isStandalonePage: boolean) {
|
public redirectAfterLoginSuccess(isStandalonePage: boolean) {
|
||||||
this.getRedirectUrl().pipe(
|
this.getRedirectUrl().pipe(
|
||||||
take(1))
|
take(1))
|
||||||
.subscribe((redirectUrl) => {
|
.subscribe((redirectUrl) => {
|
||||||
|
@@ -54,7 +54,7 @@ export class ServerAuthService extends AuthService {
|
|||||||
/**
|
/**
|
||||||
* Redirect to the route navigated before the login
|
* Redirect to the route navigated before the login
|
||||||
*/
|
*/
|
||||||
public redirectToPreviousUrl(isStandalonePage: boolean) {
|
public redirectAfterLoginSuccess(isStandalonePage: boolean) {
|
||||||
this.getRedirectUrl().pipe(
|
this.getRedirectUrl().pipe(
|
||||||
take(1))
|
take(1))
|
||||||
.subscribe((redirectUrl) => {
|
.subscribe((redirectUrl) => {
|
||||||
|
@@ -139,7 +139,7 @@ export class LogInComponent implements OnDestroy, OnInit {
|
|||||||
takeWhile(() => this.alive),
|
takeWhile(() => this.alive),
|
||||||
filter((authenticated) => authenticated))
|
filter((authenticated) => authenticated))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.authService.redirectToPreviousUrl(this.isStandalonePage);
|
this.authService.redirectAfterLoginSuccess(this.isStandalonePage);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user