[Local] Dockerized local test stack + always-show OTP in Development
CI/CD / CI · dotnet build (push) Successful in 32s
CI/CD / Deploy · hamkadr (push) Successful in 57s

Add docker-compose.local.yml + Dockerfile.local (public MS images + Liara NuGet) to run the whole app with a throwaway Postgres in one command for local testing, plus LOCAL.md. OtpService now never calls Kavenegar in the Development environment and always returns the code so the login page shows it on screen — guarantees local logins work with no SMS. Production behavior unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 19:21:47 +03:30
parent 2170ba250c
commit 6f02b1a0e9
4 changed files with 134 additions and 4 deletions
+9 -4
View File
@@ -1,5 +1,6 @@
using JobsMedical.Web.Services.Scraping;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
namespace JobsMedical.Web.Services;
@@ -13,12 +14,14 @@ public class OtpService
private readonly IMemoryCache _cache;
private readonly ISmsSender _sms;
private readonly SettingsService _settings;
private readonly IHostEnvironment _env;
public OtpService(IMemoryCache cache, ISmsSender sms, SettingsService settings)
public OtpService(IMemoryCache cache, ISmsSender sms, SettingsService settings, IHostEnvironment env)
{
_cache = cache;
_sms = sms;
_settings = settings;
_env = env;
}
private static string Key(string phone) => $"otp:{Normalize(phone)}";
@@ -33,12 +36,14 @@ public class OtpService
_cache.Set(Key(phone), code, TimeSpan.FromMinutes(5));
var settings = await _settings.GetAsync();
if (settings.SmsEnabled)
// In Development (local Docker / dotnet run) never call the SMS gateway — always show the
// code on the login screen. In Production, send via SMS only when it's enabled.
if (settings.SmsEnabled && !_env.IsDevelopment())
{
await _sms.SendOtpAsync(phone, code, settings);
return null; // never reveal the code in production
return null; // sent via SMS — don't reveal it
}
return code; // dev: surface it on screen
return code; // local/dev (or SMS off): surface it on screen
}
public bool Verify(string phone, string code)