Merge
This commit is contained in:
commit
ab1d7fef54
64 changed files with 3129 additions and 523 deletions
|
@ -69,7 +69,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
protected override string AuthenticateToken(UsernameToken token)
|
||||
{
|
||||
// try to load user account
|
||||
UserInfo user = UserController.GetUserInternally(token.Username);
|
||||
UserInfoInternal user = UserController.GetUserInternally(token.Username);
|
||||
if (user == null)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer.ContractSystem
|
|||
//
|
||||
if (customerId > -1)
|
||||
{
|
||||
ES.UserInfo userInfo = (internally) ? ES.UserController.GetUserInternally(customerId) :
|
||||
ES.UserInfoInternal userInfo = (internally) ? ES.UserController.GetUserInternally(customerId) :
|
||||
ES.UserController.GetUser(customerId);
|
||||
//
|
||||
if (internally)
|
||||
|
|
|
@ -520,12 +520,12 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
|
|||
return settings;
|
||||
}
|
||||
|
||||
private CommandParams PrepeareAccountParams(UserInfo userInfo)
|
||||
private CommandParams PrepeareAccountParams(UserInfo userInfo, string password)
|
||||
{
|
||||
CommandParams args = new CommandParams();
|
||||
|
||||
args[CommandParams.USERNAME] = userInfo.Username;
|
||||
args[CommandParams.PASSWORD] = userInfo.Password;
|
||||
args[CommandParams.PASSWORD] = password;
|
||||
args[CommandParams.FIRST_NAME] = userInfo.FirstName;
|
||||
args[CommandParams.LAST_NAME] = userInfo.LastName;
|
||||
args[CommandParams.EMAIL] = userInfo.Email;
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
|
|||
// create user account
|
||||
ES.UserInfo userInfo = new ES.UserInfo();
|
||||
userInfo.Username = account[ContractAccount.USERNAME];
|
||||
userInfo.Password = account[ContractAccount.PASSWORD];
|
||||
// userInfo.Password = account[ContractAccount.PASSWORD];
|
||||
userInfo.Email = account[ContractAccount.EMAIL];
|
||||
userInfo.FirstName = account[ContractAccount.FIRST_NAME];
|
||||
userInfo.LastName = account[ContractAccount.LAST_NAME];
|
||||
|
@ -133,7 +133,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer
|
|||
userInfo.OwnerId = contract.ResellerId;
|
||||
userInfo.Created = DateTime.Now;
|
||||
// create account
|
||||
int resultCode = ES.UserController.AddUser(userInfo, true);
|
||||
int resultCode = ES.UserController.AddUser(userInfo, true, account[ContractAccount.PASSWORD]);
|
||||
//
|
||||
if (resultCode > 0)
|
||||
{
|
||||
|
|
|
@ -1632,6 +1632,73 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return result;
|
||||
}
|
||||
|
||||
public static ResultObject SendUserPasswordRequestSms(int itemId, int accountId, string reason, string phoneTo = null)
|
||||
{
|
||||
var result = TaskManager.StartResultTask<ResultObject>("ORGANIZATION", "SEND_USER_PASSWORD_REQUEST_SMS",
|
||||
itemId);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
|
||||
if (org == null)
|
||||
{
|
||||
throw new Exception(string.Format("Organization not found (ItemId = {0})", itemId));
|
||||
}
|
||||
|
||||
UserInfo owner = PackageController.GetPackageOwner(org.PackageId);
|
||||
OrganizationUser user = OrganizationController.GetUserGeneralSettingsWithExtraData(itemId, accountId);
|
||||
|
||||
user.ItemId = itemId;
|
||||
|
||||
if (string.IsNullOrEmpty(phoneTo))
|
||||
{
|
||||
phoneTo = user.MobilePhone;
|
||||
}
|
||||
|
||||
UserSettings settings = UserController.GetUserSettings(owner.UserId, UserSettings.USER_PASSWORD_REQUEST_LETTER);
|
||||
|
||||
|
||||
string body = settings["SMSBody"];
|
||||
|
||||
var pincode = GeneratePincode();
|
||||
Guid token;
|
||||
|
||||
var items = new Hashtable();
|
||||
|
||||
items["passwordResetLink"] = GenerateUserPasswordResetLink(user.ItemId, user.AccountId, out token, pincode);
|
||||
|
||||
body = PackageController.EvaluateTemplate(body, items);
|
||||
|
||||
TaskManager.Write("Organization ID : " + user.ItemId);
|
||||
TaskManager.Write("Account : " + user.DisplayName);
|
||||
TaskManager.Write("Reason : " + reason);
|
||||
TaskManager.Write("SmsTo : " + phoneTo);
|
||||
|
||||
// send Sms message
|
||||
var response = SendSms(phoneTo, body);
|
||||
|
||||
if (response.RestException != null)
|
||||
{
|
||||
throw new Exception(response.RestException.Message);
|
||||
}
|
||||
|
||||
SetAccessTokenResponse(token, pincode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskManager.WriteError(ex);
|
||||
TaskManager.CompleteResultTask(result);
|
||||
result.AddError("", ex);
|
||||
return result;
|
||||
}
|
||||
|
||||
TaskManager.CompleteResultTask();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ResultObject SendResetUserPasswordPincodeSms(Guid token, string phoneTo = null)
|
||||
{
|
||||
var result = TaskManager.StartResultTask<ResultObject>("ORGANIZATION", "SEND_USER_PASSWORD_RESET_SMS_PINCODE");
|
||||
|
@ -1851,6 +1918,33 @@ namespace WebsitePanel.EnterpriseServer
|
|||
SendUserPasswordEmail(owner, user, reason, mailTo, logoUrl, UserSettings.USER_PASSWORD_RESET_LETTER, "USER_PASSWORD_RESET_LETTER", finalStep);
|
||||
}
|
||||
|
||||
public static void SendUserPasswordRequestEmail(int itemId, int accountId, string reason, string mailTo, bool finalStep)
|
||||
{
|
||||
// load organization
|
||||
Organization org = GetOrganization(itemId);
|
||||
|
||||
if (org == null)
|
||||
{
|
||||
throw new Exception(string.Format("Organization not found (ItemId = {0})", itemId));
|
||||
}
|
||||
|
||||
UserInfo owner = PackageController.GetPackageOwner(org.PackageId);
|
||||
OrganizationUser user = OrganizationController.GetUserGeneralSettingsWithExtraData(itemId, accountId);
|
||||
|
||||
user.ItemId = itemId;
|
||||
|
||||
if (string.IsNullOrEmpty(mailTo))
|
||||
{
|
||||
mailTo = user.PrimaryEmailAddress;
|
||||
}
|
||||
|
||||
var generalSettings = OrganizationController.GetOrganizationGeneralSettings(itemId);
|
||||
|
||||
var logoUrl = generalSettings != null ? generalSettings.OrganizationLogoUrl : string.Empty;
|
||||
|
||||
SendUserPasswordEmail(owner, user, reason, mailTo, logoUrl, UserSettings.USER_PASSWORD_REQUEST_LETTER, "USER_PASSWORD_REQUEST_LETTER", finalStep);
|
||||
}
|
||||
|
||||
public static void SendUserExpirationPasswordEmail(UserInfo owner, OrganizationUser user, string reason,
|
||||
string mailTo, string logoUrl)
|
||||
{
|
||||
|
@ -1919,8 +2013,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static AccessToken GetAccessToken(Guid accessToken, AccessTokenTypes type)
|
||||
{
|
||||
return ObjectUtils.FillObjectFromDataReader<AccessToken>(DataProvider.GetAccessTokenByAccessToken(accessToken, type));
|
||||
|
|
|
@ -422,7 +422,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return result;
|
||||
|
||||
// load user info
|
||||
UserInfo user = UserController.GetUser(userId);
|
||||
UserInfoInternal user = UserController.GetUser(userId);
|
||||
|
||||
if (createFtpAccount)
|
||||
{
|
||||
|
@ -2086,7 +2086,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
items["user"] = user;
|
||||
|
||||
// get reseller details
|
||||
UserInfo reseller = UserController.GetUser(user.OwnerId);
|
||||
UserInfoInternal reseller = UserController.GetUser(user.OwnerId);
|
||||
if (reseller != null)
|
||||
{
|
||||
reseller.Password = "";
|
||||
|
@ -2123,7 +2123,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
items["user"] = user;
|
||||
|
||||
// get reseller details
|
||||
UserInfo reseller = UserController.GetUser(user.OwnerId);
|
||||
UserInfoInternal reseller = UserController.GetUser(user.OwnerId);
|
||||
if (reseller != null)
|
||||
{
|
||||
reseller.Password = "";
|
||||
|
|
|
@ -112,10 +112,12 @@ namespace WebsitePanel.EnterpriseServer
|
|||
UserInfo user = PackageController.GetPackageOwner(item.PackageId);
|
||||
if (user != null)
|
||||
{
|
||||
UserInfoInternal userInternal = UserController.GetUserInternally(user.UserId);
|
||||
|
||||
site.StatisticsUrl = Utils.ReplaceStringVariable(site.StatisticsUrl, "username",
|
||||
HttpUtility.UrlEncode(user.Username));
|
||||
HttpUtility.UrlEncode(userInternal.Username));
|
||||
site.StatisticsUrl = Utils.ReplaceStringVariable(site.StatisticsUrl, "password",
|
||||
HttpUtility.UrlEncode(user.Password));
|
||||
HttpUtility.UrlEncode(userInternal.Password));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,5 +202,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TaskManager.CompleteTask();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckIsTwilioEnabled()
|
||||
{
|
||||
var settings = SystemController.GetSystemSettingsActive(SystemSettings.TWILIO_SETTINGS, false);
|
||||
|
||||
return settings != null
|
||||
&& !string.IsNullOrEmpty(settings.GetValueOrDefault(SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty))
|
||||
&& !string.IsNullOrEmpty(settings.GetValueOrDefault(SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty))
|
||||
&& !string.IsNullOrEmpty(settings.GetValueOrDefault(SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
try
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = GetUserInternally(username);
|
||||
UserInfoInternal user = GetUserInternally(username);
|
||||
|
||||
// check if the user exists
|
||||
if (user == null)
|
||||
|
@ -99,7 +99,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
|
||||
// compare user passwords
|
||||
if (user.Password != password)
|
||||
if (CryptoUtils.SHA1(user.Password) != password)
|
||||
{
|
||||
if (lockOut >= 0)
|
||||
DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, false);
|
||||
|
@ -145,7 +145,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
try
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = GetUserInternally(username);
|
||||
UserInfoInternal user = GetUserInternally(username);
|
||||
|
||||
// check if the user exists
|
||||
if (user == null)
|
||||
|
@ -155,8 +155,8 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
|
||||
// compare user passwords
|
||||
if (user.Password == password)
|
||||
return user;
|
||||
if (CryptoUtils.SHA1(user.Password) == password)
|
||||
return new UserInfo(user);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
items["Email"] = true;
|
||||
|
||||
// get reseller details
|
||||
UserInfo reseller = UserController.GetUser(user.OwnerId);
|
||||
UserInfoInternal reseller = UserController.GetUser(user.OwnerId);
|
||||
if (reseller != null)
|
||||
{
|
||||
reseller.Password = "";
|
||||
|
@ -264,10 +264,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
internal static UserInfo GetUserInternally(int userId)
|
||||
internal static UserInfoInternal GetUserInternally(int userId)
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(
|
||||
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
|
||||
DataProvider.GetUserByIdInternally(userId));
|
||||
|
||||
if (user != null)
|
||||
|
@ -275,10 +275,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return user;
|
||||
}
|
||||
|
||||
internal static UserInfo GetUserInternally(string username)
|
||||
internal static UserInfoInternal GetUserInternally(string username)
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(
|
||||
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
|
||||
DataProvider.GetUserByUsernameInternally(username));
|
||||
|
||||
if (user != null)
|
||||
|
@ -288,10 +288,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return user;
|
||||
}
|
||||
|
||||
public static UserInfo GetUser(int userId)
|
||||
public static UserInfoInternal GetUser(int userId)
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(
|
||||
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
|
||||
DataProvider.GetUserById(SecurityContext.User.UserId, userId));
|
||||
|
||||
if (user != null)
|
||||
|
@ -299,10 +299,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return user;
|
||||
}
|
||||
|
||||
public static UserInfo GetUser(string username)
|
||||
public static UserInfoInternal GetUser(string username)
|
||||
{
|
||||
// try to get user from database
|
||||
UserInfo user = ObjectUtils.FillObjectFromDataReader<UserInfo>(
|
||||
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
|
||||
DataProvider.GetUserByUsername(SecurityContext.User.UserId, username));
|
||||
|
||||
if (user != null)
|
||||
|
@ -381,7 +381,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
return DataProvider.GetUsers(SecurityContext.User.UserId, ownerId, recursive);
|
||||
}
|
||||
|
||||
public static int AddUser(UserInfo user, bool sendLetter)
|
||||
public static int AddUser(UserInfo user, bool sendLetter, string password)
|
||||
{
|
||||
// check account
|
||||
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo);
|
||||
|
@ -424,7 +424,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
user.IsPeer,
|
||||
user.Comments,
|
||||
user.Username.Trim(),
|
||||
CryptoUtils.Encrypt(user.Password),
|
||||
CryptoUtils.Encrypt(password),
|
||||
user.FirstName,
|
||||
user.LastName,
|
||||
user.Email,
|
||||
|
|
|
@ -119,11 +119,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
user.Email = email;
|
||||
user.SecondaryEmail = secondaryEmail;
|
||||
user.Username = username;
|
||||
user.Password = password;
|
||||
// user.Password = password;
|
||||
user.HtmlMail = htmlMail;
|
||||
|
||||
// add a new user
|
||||
createdUserId = UserController.AddUser(user, false);
|
||||
createdUserId = UserController.AddUser(user, false, password);
|
||||
if (createdUserId < 0)
|
||||
{
|
||||
// exit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue