private WorkerLoginResult Login(string workerLoginName, string workerPassword, string stationName, WorkerFunction workerFunction) { WorkerLoginResult ret; if (!string.IsNullOrEmpty(workerLoginName)) { try { CurrentWorker.LoadFromDbByLoginName(workerLoginName); PasswordManager pm = new PasswordManager(CryptoKey); ret = pm.CheckPassword(CurrentWorker.Password, workerPassword) ? WorkerLoginResult.Ok : WorkerLoginResult.Failed; if (ret == WorkerLoginResult.Ok) { ret = CurrentWorker.IsEnabledOnStation(stationName) ? WorkerLoginResult.Ok : WorkerLoginResult.NotEnabled; } if (ret == WorkerLoginResult.Ok) { if (workerFunction != WorkerFunction.None) { ret = CurrentWorker.HasPermissionTo(workerFunction) ? WorkerLoginResult.Ok : WorkerLoginResult.NotEnabled; } } } catch (Exception ex) { ExceptionMessage = ex.Message; ret = WorkerLoginResult.Failed; } } else { ret = WorkerLoginResult.Failed; } return(ret); }
private UserLoginResult Login(string loginName, string password) { UserLoginResult ret; if (!string.IsNullOrEmpty(loginName)) { try { CurrentUser.LoadFromDbByLoginName(loginName); PasswordManager pm = new PasswordManager(CryptoKey); ret = pm.CheckPassword(CurrentUser.Password, password) ? UserLoginResult.Ok : UserLoginResult.Failed; } catch (Exception ex) { ExceptionMessage = ex.Message; ret = UserLoginResult.Failed; } } else { ret = UserLoginResult.Failed; } return(ret); }