Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sharing): ensure internal sharing metadata calls pass through cus… #277

Merged
merged 1 commit into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/arcgis-rest-auth/src/UserSession.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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