Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Commit

Permalink
Call /me endpoint (fixes #63) (#75)
Browse files Browse the repository at this point in the history
Quickish fix to invoke /me endpoint, but wanted to get a version
we can deploy that will mainly work.

* redwood_token does not exist in Commons, so removed it from
User interface and tweaked code that referenced it.
* If you are not logged in, /me returns name only, so made avatar
and email optional in User interface.

To clean up, should remove redwood token references.

Also, I don't think we need to be be polling the /me endpoint, and
instead rely on #69 to handle the case where the user logs out.
  • Loading branch information
coverbeck authored Sep 26, 2018
1 parent 0c926a8 commit f1f715d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion spa/src/app/auth/_ngrx/auth.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export const selectAuthenticatedUser = createSelector(selectAuth, (state: AuthSt
*
* @type {MemoizedSelector<Object, string>}
*/
export const selectRedwoodToken = createSelector(selectAuthenticatedUser, (user: User) => user.redwood_token);
export const selectRedwoodToken = createSelector(selectAuthenticatedUser, (user: User) => null);
5 changes: 2 additions & 3 deletions spa/src/app/data/user/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export interface User {
avatar: string;
email: string;
avatar?: string;
email?: string;
name: string;
redwood_token: string;
}
2 changes: 1 addition & 1 deletion spa/src/app/data/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class UserService extends CCBaseDAO {
* @returns {Observable<User>}
*/
syncSession(): Observable<User> {
return this.get(`/api/session`);
return this.get(`/me`);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion spa/src/app/shared/cgl-toolbar/cgl-toolbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class CGLToolbarComponent {
});

this.hasRedwoodToken$ = this.authorizedUser$.map((user: User) => {
return user && user.redwood_token !== "None";
return false;
});

this.rootUrl = this.configService.getDataURL();
Expand Down

0 comments on commit f1f715d

Please sign in to comment.