Skip to content

PM-973 - fix checkIsUserInvitedToProject #1636

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

Merged
merged 1 commit into from
Apr 9, 2025
Merged

Conversation

vas3a
Copy link
Collaborator

@vas3a vas3a commented Apr 9, 2025

No description provided.

@vas3a vas3a merged commit 2422565 into develop Apr 9, 2025
2 checks passed
@vas3a vas3a deleted the PM-973_invite-by-mail branch April 9, 2025 14:28
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { toastr } from 'react-redux-toastr'
import { checkIsUserInvited } from '../../util/tc'
import { checkIsUserInvitedToProject } from '../../util/tc'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement has been updated to use checkIsUserInvitedToProject. Ensure that this function is correctly defined and exported in ../../util/tc and that all references to checkIsUserInvited in this file and others are updated accordingly.

@@ -233,13 +233,13 @@ export const checkAdminOrCopilot = (token, project) => {
return isAdmin || (isCopilot && canManageProject)
}

export const checkIsUserInvited = (token, project) => {
export const checkIsUserInvitedToProject = (token, project) => {
if (!token) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider returning a specific value (e.g., false) instead of undefined when the token is not provided, to maintain consistency in return types.

if (!token) {
return
}

const tokenData = decodeToken(token)
return project && !_.isEmpty(project) && _.find(project.invites, { userId: tokenData.userId })
return project && !_.isEmpty(project) && (_.find(project.invites, d => d.userId === tokenData.userId || d.email === tokenData.email))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition now checks for both userId and email. Ensure that this change aligns with the intended logic and that it does not introduce any security or logic issues, such as allowing access based on email when it should be restricted to userId.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant