فهرست منبع

Merge pull request #7051 from overleaf/jpa-admin-token-access-www

[web] make sure that token access links are on non admin domain

GitOrigin-RevId: 2cfadbe67244a15803caa68747de2ed33fc6d4fb
Jakob Ackermann 4 سال پیش
والد
کامیت
06bf7347d4

+ 8 - 1
services/web/frontend/js/features/share-project-modal/components/link-sharing.js

@@ -8,6 +8,7 @@ import { setProjectAccessLevel } from '../utils/api'
 import CopyLink from '../../../shared/components/copy-link'
 import CopyLink from '../../../shared/components/copy-link'
 import { useProjectContext } from '../../../shared/context/project-context'
 import { useProjectContext } from '../../../shared/context/project-context'
 import * as eventTracking from '../../../infrastructure/event-tracking'
 import * as eventTracking from '../../../infrastructure/event-tracking'
+import { useUserContext } from '../../../shared/context/user-context'
 
 
 export default function LinkSharing() {
 export default function LinkSharing() {
   const [inflight, setInflight] = useState(false)
   const [inflight, setInflight] = useState(false)
@@ -204,6 +205,8 @@ export function ReadOnlyTokenLink() {
 }
 }
 
 
 function AccessToken({ token, path, tooltipId }) {
 function AccessToken({ token, path, tooltipId }) {
+  const { isAdmin } = useUserContext()
+
   if (!token) {
   if (!token) {
     return (
     return (
       <pre className="access-token">
       <pre className="access-token">
@@ -214,7 +217,11 @@ function AccessToken({ token, path, tooltipId }) {
     )
     )
   }
   }
 
 
-  const link = `${window.location.origin}${path}${token}`
+  let origin = window.location.origin
+  if (isAdmin) {
+    origin = window.ExposedSettings.siteUrl
+  }
+  const link = `${origin}${path}${token}`
 
 
   return (
   return (
     <pre className="access-token">
     <pre className="access-token">

+ 1 - 0
services/web/frontend/js/shared/context/user-context.js

@@ -8,6 +8,7 @@ UserContext.Provider.propTypes = {
   value: PropTypes.shape({
   value: PropTypes.shape({
     user: PropTypes.shape({
     user: PropTypes.shape({
       id: PropTypes.string,
       id: PropTypes.string,
+      isAdmin: PropTypes.boolean,
       email: PropTypes.string,
       email: PropTypes.string,
       allowedFreeTrial: PropTypes.boolean,
       allowedFreeTrial: PropTypes.boolean,
       first_name: PropTypes.string,
       first_name: PropTypes.string,