private void SetRefreshToken(string refreshToken, DateTime expiresAt) { if (string.IsNullOrWhiteSpace(refreshToken)) { throw new DomainException(DomainExceptionCodes.InvalidRefreshToken, ExceptionMessageHelpers.NotEmpty(nameof(RefreshToken))); } if (RefreshToken == refreshToken && ExpiresAt == expiresAt) { return; } if (refreshToken.Length > 64) { throw new DomainException(DomainExceptionCodes.InvalidRefreshToken, ExceptionMessageHelpers.NoLongerThen(nameof(RefreshToken), 64)); } if (expiresAt <= DateTimeHelper.Now) { throw new DomainException(DomainExceptionCodes.InvalidRefreshTokenExpiresDate, "Refresh token expires date must be in the future."); } RefreshToken = refreshToken; ExpiresAt = expiresAt; }
public void SetPasswordAndSalt(string password, string salt) { if (string.IsNullOrWhiteSpace(password)) { throw new DomainException(DomainExceptionCodes.InvalidPassword, ExceptionMessageHelpers.NotEmpty(nameof(PasswordHash))); } if (string.IsNullOrWhiteSpace(salt)) { throw new DomainException(DomainExceptionCodes.InvalidSalt, ExceptionMessageHelpers.NotEmpty(nameof(PasswordSalt))); } if (PasswordHash == password && PasswordSalt == salt) { return; } if (password.Length > 64) { throw new DomainException(DomainExceptionCodes.InvalidLogin, ExceptionMessageHelpers.NoLongerThen(nameof(PasswordHash), 64)); } if (salt.Length > 64) { throw new DomainException(DomainExceptionCodes.InvalidLogin, ExceptionMessageHelpers.NoLongerThen(nameof(PasswordSalt), 64)); } PasswordHash = password; PasswordSalt = salt; }
private void SetDeviceId(string deviceId) { if (string.IsNullOrWhiteSpace(deviceId)) { throw new DomainException(DomainExceptionCodes.InvalidDeviceId, ExceptionMessageHelpers.NotEmpty(nameof(DeviceId))); } if (DeviceId == deviceId) { return; } if (deviceId.Length > 64) { throw new DomainException(DomainExceptionCodes.InvalidDeviceId, ExceptionMessageHelpers.NoLongerThen(nameof(DeviceId), 64)); } DeviceId = deviceId; }
public void SetDeviceName(string deviceName) { if (string.IsNullOrWhiteSpace(deviceName)) { throw new DomainException(DomainExceptionCodes.InvalidDeviceName, ExceptionMessageHelpers.NotEmpty(nameof(DeviceName))); } if (DeviceName == deviceName) { return; } if (deviceName.Length > 255) { throw new DomainException(DomainExceptionCodes.InvalidDeviceName, ExceptionMessageHelpers.NoLongerThen(nameof(deviceName), 255)); } DeviceName = deviceName; }
public void SetTitle(string title) { if (string.IsNullOrWhiteSpace(title)) { throw new DomainException(DomainExceptionCodes.InvalidTitle, ExceptionMessageHelpers.NotEmpty(nameof(Title))); } if (Title == title) { return; } if (title.Length > 255) { throw new DomainException(DomainExceptionCodes.InvalidTitle, ExceptionMessageHelpers.NoLongerThen(nameof(Title), 255)); } Title = title; }
public void SetLogin(string login) { if (string.IsNullOrWhiteSpace(login)) { throw new DomainException(DomainExceptionCodes.InvalidLogin, ExceptionMessageHelpers.NotEmpty(nameof(Login))); } if (Login == login) { return; } if (login.Length > 50) { throw new DomainException(DomainExceptionCodes.InvalidLogin, ExceptionMessageHelpers.NoLongerThen(nameof(Login), 50)); } Login = login; }
public void SetEmail(string email) { if (string.IsNullOrWhiteSpace(email)) { throw new DomainException(DomainExceptionCodes.InvalidEmail, ExceptionMessageHelpers.NotEmpty(nameof(Email))); } if (Email == email) { return; } if (email.Length > 255) { throw new DomainException(DomainExceptionCodes.InvalidEmail, ExceptionMessageHelpers.NoLongerThen(nameof(Email), 255)); } Email = email.Trim().ToLowerInvariant(); }
public void SetPasswordHash(string hash) { if (string.IsNullOrWhiteSpace(hash)) { throw new DomainException(DomainExceptionCodes.InvalidPassword, ExceptionMessageHelpers.NotEmpty(nameof(PasswordHash))); } if (PasswordHash == hash) { return; } if (hash.Length > 64) { throw new DomainException(DomainExceptionCodes.InvalidLogin, ExceptionMessageHelpers.NoLongerThen(nameof(PasswordHash), 64)); } PasswordHash = hash; }