Skip to content

Commit

Permalink
Merge branch '191117_Working'
Browse files Browse the repository at this point in the history
  • Loading branch information
cname87 committed Nov 17, 2019
2 parents 226de47 + cc274c0 commit 57b773b
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 63 deletions.
20 changes: 19 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,25 @@
"focus": true,
"panel": "dedicated"
},
"problemMatcher": []
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": "Connected to"
}
}
]
},
{
"label": "Check Server",
Expand Down
1 change: 0 additions & 1 deletion app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
runtime: nodejs12

env_variables:
DEBUG: PP*

# set static file cache time
default_expiration: 600s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ interface ILocationSpy {

interface IAuthServiceSpy {
isLoggedIn: boolean;
isAuthenticated$: {
subscribe: (object: { next: () => any }) => void;
};
}
describe('InformationComponent', () => {
/* setup function run by each sub test suite */
Expand All @@ -34,7 +37,11 @@ describe('InformationComponent', () => {
let authServiceSpy = jasmine.createSpyObj('authService', ['dummy']);
authServiceSpy = {
...authServiceSpy,
isLoggedIn: true,
isAuthenticated$: {
subscribe: (object: any) => {
object.next(true);
},
},
};

/* set up Testbed */
Expand Down Expand Up @@ -76,12 +83,14 @@ describe('InformationComponent', () => {
) {
const backSpy = locationSpy.back.and.stub();

authServiceSpy.isLoggedIn = isAuthenticated;
const isAuthenticatedSpy = authServiceSpy.isLoggedIn;
authServiceSpy.isAuthenticated$ = {
subscribe: (object: any) => {
object.next(isAuthenticated);
},
};

return {
backSpy,
isAuthenticatedSpy,
};
}

Expand Down
15 changes: 9 additions & 6 deletions frontend/src/app/components/information/information.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ export class InformationComponent implements OnInit {

/* set up log in only if a mode query parameter of 'login' is passed in */
} else if (this.mode === 'login') {
this.header = this.auth.isLoggedIn ? 'Log Out' : 'Log In';
this.hint = this.auth.isLoggedIn
? 'Click on the log out button above (or click on a link above)'
: 'Click on the Log In button above';
this.isGoBackVisible = false;

this.auth.isAuthenticated$.subscribe({
next: (loggedIn) => {
this.header = loggedIn ? 'Log Out' : 'Log In';
this.hint = loggedIn
? 'Click on the log out button above (or click on a link above)'
: 'Click on the Log In button above';
this.isGoBackVisible = false;
},
});
/* else set up the page not found */
} else {
this.header = 'Page Not Found';
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const profile = {
const loginPage = {
path: '/information/login',
};
const errorPage = {
path: '/information/error',
};
const loginTarget = {
path: '/dashboard',
};
Expand All @@ -42,6 +45,7 @@ export const routes = {
detail,
profile,
loginPage,
errorPage,
loginTarget,
callback,
};
Expand Down
47 changes: 0 additions & 47 deletions frontend/src/app/router/guards/login.guard.ts

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/app/shared/auth.service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class AuthService {
);

/**
* Calls the Auth0 client instance to check whether the user has logged in and been authenticated. Sets isLoggedIn to the result.
* Calls the Auth0 client instance to check whether the user has logged in and been authenticated. Emits true if authenticated and false if not and sets isLoggedIn to the result.
* Note: Called by AuthGuard to check status, i.e. when the login expires AuthGuard will direct to the login page.
*/
public isAuthenticated$ = this.auth0Client$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ToastrService } from 'ngx-toastr';

import { MessageService } from '../message-service/message.service';
import { AuthService } from '../auth.service/auth.service';
import { errorTypes } from '../../config';
import { errorTypes, routes } from '../../config';
import { environment } from '../../../environments/environment';

/* set up the rollbar service */
Expand Down Expand Up @@ -122,7 +122,7 @@ export class ErrorHandlerService implements ErrorHandler {
);
/* redirects to the login page (which will show 'login' or 'logout') */
this.zone.run(() => {
this.router.navigateByUrl('/information/login');
this.router.navigateByUrl(routes.loginPage.path);
});
return;
}
Expand All @@ -149,7 +149,7 @@ export class ErrorHandlerService implements ErrorHandler {
this.zone.run(() => {
this.log('ERROR: An unknown error occurred');
/* navigate to error information page and then show toastr message */
this.router.navigateByUrl('/information/error').then(() => {
this.router.navigateByUrl(routes.errorPage.path).then(() => {
this.logger.trace(
ErrorHandlerService.name + ': Showing toastr message',
);
Expand Down

0 comments on commit 57b773b

Please sign in to comment.