MoK: Passwort ändern ist jetzt möglich und testbereit.

This commit is contained in:
2023-07-13 13:39:41 +02:00
parent 78b73474f1
commit 691ff79d7f
11 changed files with 426 additions and 113 deletions

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Windows.Forms;
using BeWo.Data.Entities;
using BeWo.Service.Plugins;
using BeWo.Service.ServiceImplementations;
using BeWo.View.Navigation.Filter;
@@ -26,6 +27,8 @@ using DevExpress.XtraScheduler.Compatibility;
using Newtonsoft.Json;
using static BS.Shared.ServiceRecordValidationResult;
using FormCollection = System.Web.Mvc.FormCollection;
using GoalRating = BeWoPlanerMobil.Util.GoalRating;
using Image = System.Drawing.Image;
using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC;
namespace BeWoPlanerMobil.Controllers
@@ -101,6 +104,28 @@ namespace BeWoPlanerMobil.Controllers
var mokSessionTimeout = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.MoKSessionTimeout, 20);
Session.Timeout = mokSessionTimeout;
Model.IsPasswordSecurityEnabled = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.IsPasswordSecurityActiv);
if(Model.IsPasswordSecurityEnabled)
{
var tempDataValue = string.Empty;
switch(MobileSessionFacade.PasswordStrength)
{
case 0:
tempDataValue = "Sie benutzen ein sehr schwaches Passwort.<br/><br/>Bitte &auml;ndern Sie Ihr Passwort, indem Sie im Men&uuml; auf 'Password &auml;ndern' klicken.";
break;
case 1:
tempDataValue = "Sie benutzen ein schwaches Passwort.<br/><br/>Bitte &auml;ndern Sie Ihr Passwort, indem Sie im Men&uuml; auf 'Password &auml;ndern' klicken.";
break;
}
if(!string.IsNullOrEmpty(tempDataValue))
{
TempData["show_pw_change_popup"] = tempDataValue;
}
}
}
var mandatorSettings = Model.Mandator.Settings;
@@ -3807,14 +3832,23 @@ namespace BeWoPlanerMobil.Controllers
return RedirectToActionPermanent("Main");
}
var passwordUtils = new PasswordUtils();
if(passwordUtils.EvaluatePasswordStrength(newPassword) < 2)
{
var checkResult = UserService.CheckPassword(MobileSessionFacade.LoggedInUser.Oid.Value, oldPassword, newPassword);
if(!(checkResult is null))
{
TempData["passwd-change-error"] = checkResult;
return RedirectToActionPermanent("Main");
}
}
var userName = MobileSessionFacade.LoggedInUserDC.LoginName;
var userVersion = MobileSessionFacade.LoggedInUserDC.UserVersion.Value;
// ToDo: Testen! falsches oldPassword, kein oldPassword, newPassword stimmt nicht mit confirmationPassword überein, kein confirmationPassword, kein newPassword
UserService.ChangePassword(userName, userVersion, oldPassword, newPassword);
// ToDo: Regeln beachten, welche Passwortstärke mindestens erreicht werden muss.
return RedirectToActionPermanent("Main");
}
}