Skip to content

Commit

Permalink
Merge pull request #277 from Esri/patch276
Browse files Browse the repository at this point in the history
fix(sharing): ensure internal sharing metadata calls pass through cus…
  • Loading branch information
jgravois committed Aug 10, 2018
2 parents 2710f4c + e70a10d commit c09548c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
12 changes: 8 additions & 4 deletions packages/arcgis-rest-auth/src/UserSession.ts
Expand Up @@ -4,6 +4,7 @@
import * as http from "http";
import {
request,
IRequestOptions,
ArcGISAuthError,
IAuthenticationManager,
ITokenRequestOptions
Expand Down Expand Up @@ -600,17 +601,20 @@ export class UserSession implements IAuthenticationManager {
*
* @returns A Promise that will resolve with the data from the response.
*/
getUser(): Promise<IUser> {
getUser(requestOptions?: IRequestOptions): Promise<IUser> {
if (this._user && this._user.username === this.username) {
return new Promise(resolve => resolve(this._user));
} else {
const url = `${this.portal}/community/users/${encodeURIComponent(
this.username
)}`;
return request(url, {

const options = {
httpMethod: "GET",
authentication: this
}).then(response => {
authentication: this,
...requestOptions
} as IRequestOptions;
return request(url, options).then(response => {
this._user = response;
return response;
});
Expand Down
8 changes: 1 addition & 7 deletions packages/arcgis-rest-sharing/src/access.ts
@@ -1,13 +1,7 @@
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

import {
request,
IRequestOptions,
getPortalUrl
} from "@esri/arcgis-rest-request";

import { UserSession } from "@esri/arcgis-rest-auth";
import { request } from "@esri/arcgis-rest-request";

import {
ISharingRequestOptions,
Expand Down
4 changes: 2 additions & 2 deletions packages/arcgis-rest-sharing/src/helpers.ts
Expand Up @@ -49,7 +49,7 @@ export function isOrgAdmin(
): Promise<boolean> {
const session = requestOptions.authentication as UserSession;

return session.getUser().then(user => {
return session.getUser(requestOptions).then(user => {
if (!user || user.role !== "org_admin") {
return false;
} else {
Expand All @@ -67,7 +67,7 @@ export function getUserMembership(

// the response to this call is cached. yay!
return session
.getUser()
.getUser(requestOptions)
.then((user: IUser) => {
if (user.groups) {
user.groups.some(function(group: IGroup) {
Expand Down

0 comments on commit c09548c

Please sign in to comment.