From f1f715dd2ddafb417fc49ab392aba9fd3ec3e0de Mon Sep 17 00:00:00 2001 From: Charles Overbeck Date: Wed, 26 Sep 2018 09:46:56 -0700 Subject: [PATCH] Call /me endpoint (fixes #63) (#75) 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. --- spa/src/app/auth/_ngrx/auth.selectors.ts | 2 +- spa/src/app/data/user/user.model.ts | 5 ++--- spa/src/app/data/user/user.service.ts | 2 +- spa/src/app/shared/cgl-toolbar/cgl-toolbar.component.ts | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/spa/src/app/auth/_ngrx/auth.selectors.ts b/spa/src/app/auth/_ngrx/auth.selectors.ts index e6fa421..4a232e3 100644 --- a/spa/src/app/auth/_ngrx/auth.selectors.ts +++ b/spa/src/app/auth/_ngrx/auth.selectors.ts @@ -26,4 +26,4 @@ export const selectAuthenticatedUser = createSelector(selectAuth, (state: AuthSt * * @type {MemoizedSelector} */ -export const selectRedwoodToken = createSelector(selectAuthenticatedUser, (user: User) => user.redwood_token); \ No newline at end of file +export const selectRedwoodToken = createSelector(selectAuthenticatedUser, (user: User) => null); \ No newline at end of file diff --git a/spa/src/app/data/user/user.model.ts b/spa/src/app/data/user/user.model.ts index 2c6e0a5..3b82726 100644 --- a/spa/src/app/data/user/user.model.ts +++ b/spa/src/app/data/user/user.model.ts @@ -1,6 +1,5 @@ export interface User { - avatar: string; - email: string; + avatar?: string; + email?: string; name: string; - redwood_token: string; } \ No newline at end of file diff --git a/spa/src/app/data/user/user.service.ts b/spa/src/app/data/user/user.service.ts index 19be4b4..0692a15 100644 --- a/spa/src/app/data/user/user.service.ts +++ b/spa/src/app/data/user/user.service.ts @@ -17,7 +17,7 @@ export class UserService extends CCBaseDAO { * @returns {Observable} */ syncSession(): Observable { - return this.get(`/api/session`); + return this.get(`/me`); } /** diff --git a/spa/src/app/shared/cgl-toolbar/cgl-toolbar.component.ts b/spa/src/app/shared/cgl-toolbar/cgl-toolbar.component.ts index 3894985..4f8ac7e 100644 --- a/spa/src/app/shared/cgl-toolbar/cgl-toolbar.component.ts +++ b/spa/src/app/shared/cgl-toolbar/cgl-toolbar.component.ts @@ -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();