Skip to content

Add DisableEmailPasswordLogin setting for Microsoft-only sign-in#230

Merged
hamzahalq merged 1 commit into
releases/r8.0from
hamza/feature/disable-email-password-login
Jul 23, 2026
Merged

Add DisableEmailPasswordLogin setting for Microsoft-only sign-in#230
hamzahalq merged 1 commit into
releases/r8.0from
hamza/feature/disable-email-password-login

Conversation

@hamzahalq

Copy link
Copy Markdown
Contributor

When enabled, admins can't set a password on new accounts and the Login handler rejects any email/password attempt outright.

When enabled, admins can't set a password on new accounts and the
Login handler rejects any email/password attempt outright.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Password login control

Layer / File(s) Summary
Configuration contract and exposure
SW.Bitween.Api/Services/BitweenOptions.cs, SW.Bitween.Api/Resources/Settings/Config.cs
Adds DisableEmailPasswordLogin to BitweenOptions and includes its value in the settings response.
Conditional account creation
SW.Bitween.Api/Resources/Accounts/Create.cs
Makes password validation and hashing conditional; disabled password login permits an empty password and stores no password hash.
Login enforcement
SW.Bitween.Api/Resources/Accounts/Login.cs
Rejects email/password login when disabled unless a refresh token or Microsoft token is provided.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: security, risk:high

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the new Microsoft-only sign-in setting and its effect on email/password login.
Description check ✅ Passed The description is directly related to the change and accurately describes the disabled password and login rejection behavior.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@SW.Bitween.Api/Resources/Accounts/Create.cs`:
- Around line 35-42: Update the Account domain property and constructor contract
to use nullable string types for Password, allowing Create to pass null when
DisableEmailPasswordLogin is enabled. Preserve existing SetPassword and Login
behavior for accounts with hashes, and add the required migration separately if
deployed schemas still enforce a non-null Accounts.Password column.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: simplify9/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bff89896-4832-4333-9c72-96bcf158748d

📥 Commits

Reviewing files that changed from the base of the PR and between 83056fe and 75b27ac.

📒 Files selected for processing (4)
  • SW.Bitween.Api/Resources/Accounts/Create.cs
  • SW.Bitween.Api/Resources/Accounts/Login.cs
  • SW.Bitween.Api/Resources/Settings/Config.cs
  • SW.Bitween.Api/Services/BitweenOptions.cs
📜 Review details
🔇 Additional comments (4)
SW.Bitween.Api/Services/BitweenOptions.cs (1)

48-55: LGTM!

SW.Bitween.Api/Resources/Settings/Config.cs (1)

26-26: LGTM!

SW.Bitween.Api/Resources/Accounts/Login.cs (1)

64-70: LGTM!

SW.Bitween.Api/Resources/Accounts/Create.cs (1)

53-57: 🩺 Stability & Availability

Ensure nested Validate validators can resolve through DI.

SW.CqApi registers validators from the handler assembly, but private class Validate : AbstractValidator<...> constructors still need to be resolvable. Accounts/Create.cs:53 requires BitweenOptions; if DI resolution is not used here, account creation validation will fail before command handling. Add/confirm DI registration and a validation-path test for create-account requests.

Comment on lines +35 to +42
var password = _bitweenOptions.DisableEmailPasswordLogin
? null
: SecurePasswordHasher.Hash(request.Password);

var newAccount = new Account(
request.Name,
request.Email,
SecurePasswordHasher.Hash(request.Password),
password,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C3 '<Nullable>|Password|IsRequired' \
  --glob '*.csproj' --glob '*.cs' --glob '*.sql' SW.Bitween.Api

Repository: simplify9/Bitween-api

Length of output: 29759


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Project files:\n'
git ls-files '*.*proj' | sed -n '1,80p'

printf '\nSW.Bitween.Api.csproj:\n'
cat -n SW.Bitween.Api/SW.Bitween.Api.csproj

printf '\nAccount.cs:\n'
cat -n SW.Bitween.Api/Domain/Accounts/Account.cs | sed -n '1,80p'

printf '\nDbContext Account mapping relevant lines:\n'
cat -n SW.Bitween.Api/Data/BitweenDbContext.cs | sed -n '330,375p'

printf '\nMigrations mentioning Password field/column/constraint:\n'
git ls-files | grep -E '(^|/Migrations/.*\.cs$|\.sql$|\.md$)' | xargs rg -n -i 'password|account' --glob '*.cs' --glob '*.sql' --glob '*.md' | sed -n '1,220p'

Repository: simplify9/Bitween-api

Length of output: 47971


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Project files:\n'
git ls-files '*.*proj' | sed -n '1,80p'

printf '\nSW.Bitween.Api.csproj:\n'
cat -n SW.Bitween.Api/SW.Bitween.Api.csproj

printf '\nAccount.cs:\n'
cat -n SW.Bitween.Api/Domain/Accounts/Account.cs | sed -n '1,80p'

printf '\nDbContext Account mapping relevant lines:\n'
cat -n SW.Bitween.Api/Data/BitweenDbContext.cs | sed -n '330,375p'

printf '\nMigrations mentioning Password field/column/constraint:'
git ls-files | grep -E '(^|/Migrations/.*\.cs$|\.sql$|\.md$)' | xargs rg -n -i 'password|account' --glob '*.cs' --glob '*.sql' --glob '*.md' | sed -n '1,220p'

Repository: simplify9/Bitween-api

Length of output: 47903


Make Password nullable before passing null into Account.

Account’s constructor and Password are non-nullable string. EF mapping leaves Accounts.Password nullable, but the model still allows null while other paths like SetPassword/Login still expect a hash. Change the domain property/constructor contract to string? and add an out-of-band migration if deployed schemas don’t allow null yet.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SW.Bitween.Api/Resources/Accounts/Create.cs` around lines 35 - 42, Update the
Account domain property and constructor contract to use nullable string types
for Password, allowing Create to pass null when DisableEmailPasswordLogin is
enabled. Preserve existing SetPassword and Login behavior for accounts with
hashes, and add the required migration separately if deployed schemas still
enforce a non-null Accounts.Password column.

@hamzahalq
hamzahalq merged commit a279f62 into releases/r8.0 Jul 23, 2026
5 checks passed
@hamzahalq
hamzahalq deleted the hamza/feature/disable-email-password-login branch July 23, 2026 10:15
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.

2 participants