Skip to content

Wiser-Frontend Developer Test completed By Tian Liu - #12

Open
hnamdev008 wants to merge 3 commits into
wearewiser:developfrom
hnamdev008:master
Open

hnamdev008 wants to merge 3 commits into
wearewiser:developfrom
hnamdev008:master

Conversation

@hnamdev008

Copy link
Copy Markdown

No description provided.

@johnfedoruk johnfedoruk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Testing:

  • Lint: fails
  • Test: fails
  • Coverage: fails
  • Build: fails

Manual Review

  • No demonstration of Angular animation implementation
  • Good use of services
  • Has auth guards
  • No readme describing changes
  • Good use of form logic
  • No lazy loading
  • No application modules
  • Has shared module for auth service
  • Authentication broken (refresh doesn't work)
  • Using promises, but no async
  • Use of local storage for a JWT is a security vulnerability.
  • Good directory structure
  • Would like to see more typescript features (privacy modifiers / return types / type setting)

Comment thread package.json
"tslint": "~5.9.1",
"typescript": "~2.5.3"
"typescript": "~2.5.3",
"jwt-decode": "2.2.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JWT not required

Comment thread src/app/app.module.ts
},
{
path: 'secure',
component: SecureComponent,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be lazy loaded

Comment thread src/app/app.module.ts
path: 'error/:status_code',
component: ErrorComponent
},
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The paths /auth/login and auth/logout are supposed to be handled by a distinct application module

Comment thread src/app/app.module.ts
{
path: 'secure',
component: SecureComponent,
canActivate: [AuthGuard]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

#password="ngModel"
id="password"
class="w3-input ng-untouched ng-pristine ng-valid" name="password" type="password" />
<div [hidden]="password.valid || password.pristine" class="alert alert-danger">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

export class AuthService {

_baseURL = "https://dev-test-service.madebywiser.com";
_userName = "";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a privacy modifier of private

@Injectable()
export class AuthService {

_baseURL = "https://dev-test-service.madebywiser.com";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a privacy modifier of private

localStorage.setItem(username, JSON.stringify({ username: username, token: data }));

this.profile$.next({
username: username;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using semi-colons does not comply with JSON standards.

.then((data)=>
{
this._userName = username;
localStorage.setItem(username, JSON.stringify({ username: username, token: data }));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using localStorage is a security vulnerability - should be using sessionStorage

private authService: AuthService) {}

canActivate() {
if (!this.authService.isTokenExpired()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does nothing to help in the situation in which the window is refreshed. Also, it doesn't validate that the token has been signed by the server after performing a login.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants