1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-22 20:11:04 -05:00

apply the condition suggestion

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
Cy Okeke 2025-05-22 13:29:22 +01:00
parent d9dd428759
commit cf5ea934ad
No known key found for this signature in database
GPG Key ID: 88B341B55C84B45C

View File

@ -259,19 +259,23 @@ public class OrganizationsController : Controller
{ {
var freePlan = await _pricingClient.GetPlanOrThrow(model.PlanType.Value); var freePlan = await _pricingClient.GetPlanOrThrow(model.PlanType.Value);
var isDowngradingToFree = organization.PlanType != PlanType.Free && model.PlanType.Value == PlanType.Free; var isDowngradingToFree = organization.PlanType != PlanType.Free && model.PlanType.Value == PlanType.Free;
switch (isDowngradingToFree) if (isDowngradingToFree)
{ {
case true when model.Seats.HasValue && model.Seats.Value > freePlan.PasswordManager.MaxSeats: if (model.Seats.HasValue && model.Seats.Value > freePlan.PasswordManager.MaxSeats)
{
TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxSeats} seats cannot be downgraded to the Free plan"; TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxSeats} seats cannot be downgraded to the Free plan";
return RedirectToAction("Edit", new { id }); return RedirectToAction("Edit", new { id });
case true when model.MaxCollections > freePlan.PasswordManager.MaxCollections: }
if (model.MaxCollections > freePlan.PasswordManager.MaxCollections)
{
TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxCollections} collections cannot be downgraded to the Free plan. Your organization currently has {organization.MaxCollections} collections."; TempData["Error"] = $"Organizations with more than {freePlan.PasswordManager.MaxCollections} collections cannot be downgraded to the Free plan. Your organization currently has {organization.MaxCollections} collections.";
return RedirectToAction("Edit", new { id }); return RedirectToAction("Edit", new { id });
case true: }
model.MaxStorageGb = null;
model.ExpirationDate = null; model.MaxStorageGb = null;
model.Enabled = true; model.ExpirationDate = null;
break; model.Enabled = true;
} }
} }