Skip to content

fix(data-sync): correct always-true auth condition in workarea#366

Open
Kaushik-Kumar-CEG wants to merge 1 commit into
PSMRI:mainfrom
Kaushik-Kumar-CEG:fix/datasync-auth-condition-logic
Open

fix(data-sync): correct always-true auth condition in workarea#366
Kaushik-Kumar-CEG wants to merge 1 commit into
PSMRI:mainfrom
Kaushik-Kumar-CEG:fix/datasync-auth-condition-logic

Conversation

@Kaushik-Kumar-CEG
Copy link
Copy Markdown

📋 Description

The serverKey null-check in DataSync WorkareaComponent.ngOnInit() uses !== null || !== undefined, which is always true (De Morgan's law). The else branch that redirects unauthenticated users to datasync/sync-login never executes.

Replaced with a truthy check on an extracted variable, which also avoids calling getItem() (and its decryption logic) twice.

Additionally inverted an empty if block for the inventory sync response to fix a pre-existing lint error (no-empty).

✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)

ℹ️ Additional Information

Before (always true):

if (
  this.sessionstorage.getItem('serverKey') !== null ||
  this.sessionstorage.getItem('serverKey') !== undefined
)

After:

const serverKey = this.sessionstorage.getItem('serverKey');
if (serverKey) {

Truth table proving the bug:

getItem() returns !== null !== undefined || result
null false true true
undefined true false true
"abc" true true true

The else branch was dead code.

… workarea

The condition `!== null || !== undefined` is always true (De Morgan's
law), preventing the else branch from ever redirecting unauthenticated
users to the sync-login page. Replace with a truthy check on the
extracted variable.

Also invert empty if-block for inventory sync response to fix lint
error.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Warning

Review limit reached

@Kaushik-Kumar-CEG, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 9 minutes and 53 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c21f8ea8-3837-4f70-9751-fa331021055f

📥 Commits

Reviewing files that changed from the base of the PR and between 8c270f9 and 67f0398.

📒 Files selected for processing (1)
  • src/app/app-modules/data-sync/workarea/workarea.component.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@Kaushik-Kumar-CEG
Copy link
Copy Markdown
Author

Hi @snehar-nd @drtechie — this fixes a logic bug where the DataSync workarea auth check never redirects unauthenticated users. Related to PSMRI/AMRIT#130 (C4GT DMP 2026).

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