This commit is contained in:
Virtuworks 2015-05-18 19:30:52 -04:00
commit 7726069290
18 changed files with 1591 additions and 125 deletions

View file

@ -44365,7 +44365,7 @@ Hello #user.FirstName#,
</p> </p>
<p> <p>
Please, find below details of your control panel account. Please, find below details of your control panel account. The one time password was generated for you. You should change the password after login.
</p> </p>
<h1>Control Panel URL</h1> <h1>Control Panel URL</h1>
@ -44374,7 +44374,7 @@ Please, find below details of your control panel account.
<tr> <tr>
<th>Control Panel URL</th> <th>Control Panel URL</th>
<th>Username</th> <th>Username</th>
<th>Password</th> <th>One Time Password</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -44412,11 +44412,11 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property
Hello #user.FirstName#, Hello #user.FirstName#,
Please, find below details of your control panel account. Please, find below details of your control panel account. The one time password was generated for you. You should change the password after login.
Control Panel URL: http://panel.AcmeHosting.com Control Panel URL: http://panel.AcmeHosting.com
Username: #user.Username# Username: #user.Username#
Password: #user.Password# One Time Password: #user.Password#
If you have any questions regarding your hosting account, feel free to contact our support department at any time. If you have any questions regarding your hosting account, feel free to contact our support department at any time.

File diff suppressed because it is too large Load diff

View file

@ -67,6 +67,9 @@ namespace WebsitePanel.EnterpriseServer
public const int ERROR_USER_ACCOUNT_DISABLED = -114; public const int ERROR_USER_ACCOUNT_DISABLED = -114;
public const int ERROR_USER_ACCOUNT_LOCKEDOUT = -115; public const int ERROR_USER_ACCOUNT_LOCKEDOUT = -115;
public const int ERROR_USER_EXPIRED_ONETIMEPASSWORD = -116;
#endregion #endregion
#region Packages #region Packages

View file

@ -0,0 +1,43 @@
// Copyright (c) 2015, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
namespace WebsitePanel.EnterpriseServer
{
public class BusinessSuccessCodes
{
#region Users
public const int SUCCESS_USER_ONETIMEPASSWORD = 100;
#endregion
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebsitePanel.EnterpriseServer
{
public enum OneTimePasswordStates
{
None = 0,
Active = 1,
Expired = 2,
}
}

View file

@ -385,68 +385,19 @@ namespace WebsitePanel.EnterpriseServer
public class UserInfoInternal : UserInfo public class UserInfoInternal : UserInfo
{ {
private string password; private string password;
private string oneTimePassword;
private OneTimePasswordStates oneTimePasswordState;
public string Password public string Password
{ {
get { return this.password; } get { return this.password; }
set { this.password = value; } set { this.password = value; }
} }
public OneTimePasswordStates OneTimePasswordState
{
get { return oneTimePasswordState; }
set { oneTimePasswordState = value; }
}
}; };
} }
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esAuthentication.asmx.cs(51): public int AuthenticateUser(string username, string password, string ip)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esAuthentication.asmx.cs(57): public UserInfo GetUserByUsernamePassword(string username, string password, string ip)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esAuthentication.asmx.cs(63): public int ChangeUserPasswordByUsername(string username, string oldPassword, string newPassword, string ip)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esAuthentication.asmx.cs(69): public int SendPasswordReminder(string username, string ip)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esAuthentication.asmx.cs(81): public int SetupControlPanelAccounts(string passwordA, string passwordB, string ip)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esBlackBerry.asmx.cs(92): public ResultObject SetActivationPasswordWithExpirationTime(int itemId, int accountId, string password, int time)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esExchangeServer.asmx.cs(221): public bool CheckAccountCredentials(int itemId, string email, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esExchangeServer.asmx.cs(231): public int CreateMailbox(int itemId, int accountId, ExchangeAccountType accountType, string accountName, string displayName,
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esExchangeServer.asmx.cs(231): string name, string domain, string password, bool sendSetupInstructions, string setupInstructionMailAddress, int mailboxPlanId, int archivedPlanId, string subscriberNumber, bool EnableArchiving)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(195): public ResultObject SendResetUserPasswordLinkSms(int itemId, int accountId, string reason, string phoneTo = null)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(197): return OrganizationController.SendResetUserPasswordLinkSms(itemId, accountId, reason, phoneTo);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(202): public ResultObject SendResetUserPasswordPincodeSms(Guid token, string phoneTo = null)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(204): return OrganizationController.SendResetUserPasswordPincodeSms(token, phoneTo);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(259): public int CreateUser(int itemId, string displayName, string name, string domain, string password, string subscriberNumber, bool sendNotification, string to)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(262): return OrganizationController.CreateUser(itemId, displayName, name, domain, password, subscriberNumber, true, sendNotification, to, out accountName);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(266): public int ImportUser(int itemId, string accountName, string displayName, string name, string domain, string password, string subscriberNumber)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(268): return OrganizationController.ImportUser(itemId, accountName, displayName, name, domain, password, subscriberNumber);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(293): string password, bool hideAddressBook, bool disabled, bool locked, string firstName, string initials,
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(298): bool userMustChangePassword)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(301): password, hideAddressBook, disabled, locked, firstName, initials,
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(305): webPage, notes, externalEmail, subscriberNumber, levelId, isVIP, userMustChangePassword);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(318): public int SetUserPassword(int itemId, int accountId, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(320): return OrganizationController.SetUserPassword(itemId, accountId, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(353): public PasswordPolicyResult GetPasswordPolicy(int itemId)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(355): return OrganizationController.GetPasswordPolicy(itemId);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(359): public void SendResetUserPasswordEmail(int itemId, int accountId, string reason, string mailTo, bool finalStep)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esOrganizations.asmx.cs(361): OrganizationController.SendResetUserPasswordEmail(itemId, accountId, reason, mailTo, finalStep);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esPackages.asmx.cs(449): public int CreateUserWizard(int parentPackageId, string username, string password,
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esPackages.asmx.cs(456): return UserCreationWizard.CreateUserAccount(parentPackageId, username, password,
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esServers.asmx.cs(108): public int CheckServerAvailable(string serverUrl, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esServers.asmx.cs(110): return ServerController.CheckServerAvailable(serverUrl, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esServers.asmx.cs(126): public int UpdateServerConnectionPassword(int serverId, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esServers.asmx.cs(128): return ServerController.UpdateServerConnectionPassword(serverId, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esServers.asmx.cs(132): public int UpdateServerADPassword(int serverId, string adPassword)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esServers.asmx.cs(134): return ServerController.UpdateServerADPassword(serverId, adPassword);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esUsers.asmx.cs(152): string password,
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esUsers.asmx.cs(178): user.Password = password;
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esUsers.asmx.cs(272): public int ChangeUserPassword(int userId, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esUsers.asmx.cs(274): return UserController.ChangeUserPassword(userId, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(127): return WebServerController.InstallFrontPage(siteItemId, username, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(137): public int ChangeFrontPagePassword(int siteItemId, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(139): return WebServerController.ChangeFrontPagePassword(siteItemId, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(337): public ResultObject GrantWebDeployPublishingAccess(int siteItemId, string accountName, string accountPassword)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(339): return WebServerController.GrantWebDeployPublishingAccess(siteItemId, accountName, accountPassword);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(361): public ResultObject ChangeWebDeployPublishingPassword(int siteItemId, string newAccountPassword)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(363): return WebServerController.ChangeWebDeployPublishingPassword(siteItemId, newAccountPassword);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(536): public ResultObject GrantWebManagementAccess(int siteItemId, string accountName, string accountPassword)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(538): return WebServerController.GrantWebManagementAccess(siteItemId, accountName, accountPassword);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(548): public ResultObject ChangeWebManagementAccessPassword(int siteItemId, string accountPassword)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(550): return WebServerController.ChangeWebManagementAccessPassword(siteItemId, accountPassword);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(567): public ResultObject InstallPfx(byte[] certificate, int siteItemId, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(569): return WebServerController.InstallPfx(certificate, siteItemId, password);
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(597): public byte[] ExportCertificate(int siteId, string serialNumber, string password)
//C:\Work\WSPExpert\WebsitePanel\Sources\WebsitePanel.EnterpriseServer\esWebServers.asmx.cs(599): return WebServerController.ExportCertificate(siteId, serialNumber, password);

View file

@ -69,6 +69,7 @@
<Compile Include="..\VersionInfo.cs"> <Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link> <Link>VersionInfo.cs</Link>
</Compile> </Compile>
<Compile Include="Common\BusinessSuccessCodes.cs" />
<Compile Include="Common\BusinessErrorCodes.cs" /> <Compile Include="Common\BusinessErrorCodes.cs" />
<Compile Include="Common\GenericStringResult.cs"> <Compile Include="Common\GenericStringResult.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
@ -165,6 +166,7 @@
<Compile Include="Tasks\BackgroundTask.cs" /> <Compile Include="Tasks\BackgroundTask.cs" />
<Compile Include="Tasks\BackgroundTaskLogRecord.cs" /> <Compile Include="Tasks\BackgroundTaskLogRecord.cs" />
<Compile Include="Tasks\BackgroundTaskStatus.cs" /> <Compile Include="Tasks\BackgroundTaskStatus.cs" />
<Compile Include="Users\OneTimePasswordStates.cs" />
<Compile Include="Users\UserInfo.cs" /> <Compile Include="Users\UserInfo.cs" />
<Compile Include="Users\UserLoginStatus.cs" /> <Compile Include="Users\UserLoginStatus.cs" />
<Compile Include="Users\UsernamePolicy.cs" /> <Compile Include="Users\UsernamePolicy.cs" />

View file

@ -382,6 +382,15 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@password", password)); new SqlParameter("@password", password));
} }
public static void SetUserOneTimePassword(int userId, string password, int auths)
{
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
ObjectQualifier + "SetUserOneTimePassword",
new SqlParameter("@UserID", userId),
new SqlParameter("@Password", password),
new SqlParameter("@OneTimePasswordState", auths));
}
#endregion #endregion
#region User Settings #region User Settings

View file

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebsitePanel.EnterpriseServer
{
public class OneTimePasswordHelper
{
public static string SetOneTimePassword(int userId)
{
int passwordLength = 12; // default length
// load password policy
UserSettings userSettings = UserController.GetUserSettings(userId, UserSettings.WEBSITEPANEL_POLICY);
string passwordPolicy = userSettings["PasswordPolicy"];
if (!String.IsNullOrEmpty(passwordPolicy))
{
// get third parameter - max length
try
{
passwordLength = Utils.ParseInt(passwordPolicy.Split(';')[2].Trim(), passwordLength);
}
catch { /* skip */ }
}
// generate password
var password = Utils.GetRandomString(passwordLength);
DataProvider.SetUserOneTimePassword(userId, CryptoUtils.Encrypt(password), (int) OneTimePasswordStates.Active);
return password;
}
public static void FireSuccessAuth(UserInfoInternal user)
{
DataProvider.SetUserOneTimePassword(user.UserId, CryptoUtils.Encrypt(user.Password), (int) OneTimePasswordStates.Expired);
}
}
}

View file

@ -57,6 +57,8 @@ namespace WebsitePanel.EnterpriseServer
try try
{ {
int result = 0;
// try to get user from database // try to get user from database
UserInfoInternal user = GetUserInternally(username); UserInfoInternal user = GetUserInternally(username);
@ -99,16 +101,31 @@ namespace WebsitePanel.EnterpriseServer
// compare user passwords // compare user passwords
if (CryptoUtils.SHA1(user.Password) != password) if (CryptoUtils.SHA1(user.Password) == password)
{
switch (user.OneTimePasswordState)
{
case OneTimePasswordStates.Active:
result = BusinessSuccessCodes.SUCCESS_USER_ONETIMEPASSWORD;
OneTimePasswordHelper.FireSuccessAuth(user);
break;
case OneTimePasswordStates.Expired:
if (lockOut >= 0) DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, false);
TaskManager.WriteWarning("Expired one time password");
return BusinessErrorCodes.ERROR_USER_EXPIRED_ONETIMEPASSWORD;
break;
}
}
else
{ {
if (lockOut >= 0) if (lockOut >= 0)
DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, false); DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, false);
TaskManager.WriteWarning("Wrong password"); TaskManager.WriteWarning("Wrong password");
return BusinessErrorCodes.ERROR_USER_WRONG_PASSWORD; return BusinessErrorCodes.ERROR_USER_WRONG_PASSWORD;
} }
else
DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, true); DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, true);
// check status // check status
if (user.Status == UserStatus.Cancelled) if (user.Status == UserStatus.Cancelled)
@ -123,7 +140,7 @@ namespace WebsitePanel.EnterpriseServer
return BusinessErrorCodes.ERROR_USER_ACCOUNT_PENDING; return BusinessErrorCodes.ERROR_USER_ACCOUNT_PENDING;
} }
return 0; return result;
} }
catch (Exception ex) catch (Exception ex)
@ -155,7 +172,7 @@ namespace WebsitePanel.EnterpriseServer
} }
// compare user passwords // compare user passwords
if (CryptoUtils.SHA1(user.Password) == password) if (CryptoUtils.SHA1(user.Password) == password)
return new UserInfo(user); return new UserInfo(user);
return null; return null;
@ -210,7 +227,7 @@ namespace WebsitePanel.EnterpriseServer
try try
{ {
// try to get user from database // try to get user from database
UserInfo user = GetUserInternally(username); UserInfoInternal user = GetUserInternally(username);
if (user == null) if (user == null)
{ {
TaskManager.WriteWarning("Account not found"); TaskManager.WriteWarning("Account not found");
@ -232,18 +249,20 @@ namespace WebsitePanel.EnterpriseServer
if (body == null || body == "") if (body == null || body == "")
return BusinessErrorCodes.ERROR_SETTINGS_PASSWORD_LETTER_EMPTY_BODY; return BusinessErrorCodes.ERROR_SETTINGS_PASSWORD_LETTER_EMPTY_BODY;
// One Time Password feature
user.Password = OneTimePasswordHelper.SetOneTimePassword(user.UserId);
// set template context items // set template context items
Hashtable items = new Hashtable(); Hashtable items = new Hashtable();
items["user"] = user; items["user"] = user;
items["Email"] = true; items["Email"] = true;
// get reseller details // get reseller details
UserInfoInternal reseller = UserController.GetUser(user.OwnerId); UserInfoInternal reseller = UserController.GetUser(user.OwnerId);
if (reseller != null) if (reseller != null)
{ {
reseller.Password = ""; items["reseller"] = new UserInfo(reseller);
items["reseller"] = reseller;
} }
subject = PackageController.EvaluateTemplate(subject, items); subject = PackageController.EvaluateTemplate(subject, items);
@ -264,52 +283,40 @@ namespace WebsitePanel.EnterpriseServer
} }
} }
internal static UserInfoInternal GetUserInternally(int userId) internal static UserInfoInternal GetUserInternally(int userId)
{ {
// try to get user from database return GetUser(DataProvider.GetUserByIdInternally(userId));
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
DataProvider.GetUserByIdInternally(userId));
if (user != null)
user.Password = CryptoUtils.Decrypt(user.Password);
return user;
} }
internal static UserInfoInternal GetUserInternally(string username) internal static UserInfoInternal GetUserInternally(string username)
{ {
// try to get user from database return GetUser(DataProvider.GetUserByUsernameInternally(username));
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
DataProvider.GetUserByUsernameInternally(username));
if (user != null)
{
user.Password = CryptoUtils.Decrypt(user.Password);
}
return user;
} }
public static UserInfoInternal GetUser(int userId) public static UserInfoInternal GetUser(int userId)
{ {
// try to get user from database return GetUser(DataProvider.GetUserById(SecurityContext.User.UserId, userId));
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
DataProvider.GetUserById(SecurityContext.User.UserId, userId));
if (user != null)
user.Password = CryptoUtils.Decrypt(user.Password);
return user;
} }
public static UserInfoInternal GetUser(string username) public static UserInfoInternal GetUser(string username)
{ {
// try to get user from database return GetUser(DataProvider.GetUserByUsername(SecurityContext.User.UserId, username));
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(
DataProvider.GetUserByUsername(SecurityContext.User.UserId, username));
if (user != null)
user.Password = CryptoUtils.Decrypt(user.Password);
return user;
} }
private static UserInfoInternal GetUser(IDataReader reader)
{
// try to get user from database
UserInfoInternal user = ObjectUtils.FillObjectFromDataReader<UserInfoInternal>(reader);
if (user != null)
{
user.Password = CryptoUtils.Decrypt(user.Password);
}
return user;
}
public static List<UserInfo> GetUserParents(int userId) public static List<UserInfo> GetUserParents(int userId)
{ {
// get users from database // get users from database

View file

@ -183,6 +183,7 @@
<Compile Include="Tasks\TaskController.cs" /> <Compile Include="Tasks\TaskController.cs" />
<Compile Include="Tasks\TaskEventHandler.cs" /> <Compile Include="Tasks\TaskEventHandler.cs" />
<Compile Include="Tasks\TaskManager.cs" /> <Compile Include="Tasks\TaskManager.cs" />
<Compile Include="Users\Helpers\OneTimePasswordHelper.cs" />
<Compile Include="Users\UserAsyncWorker.cs" /> <Compile Include="Users\UserAsyncWorker.cs" />
<Compile Include="Users\UserController.cs" /> <Compile Include="Users\UserController.cs" />
<Compile Include="Virtualization2012\CreateServerAsyncWorker2012.cs" /> <Compile Include="Virtualization2012\CreateServerAsyncWorker2012.cs" />

View file

@ -401,7 +401,8 @@
<Controls> <Controls>
<Control key="" src="WebsitePanel/Login.ascx" title="SignIn" type="View" /> <Control key="" src="WebsitePanel/Login.ascx" title="SignIn" type="View" />
<Control key="forgot_password" src="WebsitePanel/LoginForgotPassword.ascx" title="PasswordReminder" type="View" /> <Control key="forgot_password" src="WebsitePanel/LoginForgotPassword.ascx" title="PasswordReminder" type="View" />
<Control key="scpa" src="WebsitePanel/SetupControlPanelAccounts.ascx" title="SetupControlPanelAccounts" type="View" /> <Control key="change_onetimepassword" src="WebsitePanel/UserAccountChangePassword.ascx" title="UserAccountChangePassword" type="View" icon="admin_lock_48.png" />
<Control key="scpa" src="WebsitePanel/SetupControlPanelAccounts.ascx" title="SetupControlPanelAccounts" type="View" />
</Controls> </Controls>
</ModuleDefinition> </ModuleDefinition>
<ModuleDefinition id="AuditLog"> <ModuleDefinition id="AuditLog">

View file

@ -4581,6 +4581,9 @@
<data name="Error.ERROR_USER_ACCOUNT_SUSPENDED" xml:space="preserve"> <data name="Error.ERROR_USER_ACCOUNT_SUSPENDED" xml:space="preserve">
<value>User account is Suspended</value> <value>User account is Suspended</value>
</data> </data>
<data name="Warning.USER_SHOULD_CHANGE_ONETIMEPASSWORD" xml:space="preserve">
<value>You should change your one time password.</value>
</data>
<data name="VPS.VPS_CREATE_EMPTY_HOSTNAME_PATTERN" xml:space="preserve"> <data name="VPS.VPS_CREATE_EMPTY_HOSTNAME_PATTERN" xml:space="preserve">
<value>Hostname pattern is not specified. Could not create VPS with blank hostname.</value> <value>Hostname pattern is not specified. Could not create VPS with blank hostname.</value>
</data> </data>
@ -5289,6 +5292,9 @@
<data name="UserItemType.ExchangeAccount" xml:space="preserve"> <data name="UserItemType.ExchangeAccount" xml:space="preserve">
<value>Exchange Account</value> <value>Exchange Account</value>
</data> </data>
<data name="UserItemType.Users" xml:space="preserve">
<value>Account Home</value>
</data>
<data name="Error.WEB_PUB_DISABLE" xml:space="preserve"> <data name="Error.WEB_PUB_DISABLE" xml:space="preserve">
<value>Could not disable access to Web Publishing feature for the account specified</value> <value>Could not disable access to Web Publishing feature for the account specified</value>
</data> </data>

View file

@ -382,7 +382,7 @@ namespace WebsitePanel.Portal
else return BusinessErrorCodes.ERROR_USER_ACCOUNT_ROLE_NOT_ALLOWED; else return BusinessErrorCodes.ERROR_USER_ACCOUNT_ROLE_NOT_ALLOWED;
} }
return 0; return authResult;
} }
} }
catch (Exception ex) catch (Exception ex)

View file

@ -102,6 +102,7 @@ namespace WebsitePanel.WebPortal
obj["ItemID"] = row["ItemID"].ToString(); obj["ItemID"] = row["ItemID"].ToString();
obj["PackageID"] = row["PackageID"].ToString(); obj["PackageID"] = row["PackageID"].ToString();
obj["FullType"] = "Space"; obj["FullType"] = "Space";
obj["FullTypeLocalized"] = GetTypeDisplayName("Space");
obj["AccountID"] = row["AccountID"].ToString(); obj["AccountID"] = row["AccountID"].ToString();
dataList.Add(obj); dataList.Add(obj);
} }
@ -117,17 +118,23 @@ namespace WebsitePanel.WebPortal
String.Format("%{0}%", filterValue), 0, 0, "", iNumResults, columnType, fullType); String.Format("%{0}%", filterValue), 0, 0, "", iNumResults, columnType, fullType);
DataTable dt = dsObjectItems.Tables[2]; DataTable dt = dsObjectItems.Tables[2];
List<Dictionary<string, string>> dataList = new List<Dictionary<string, string>>(); List<Dictionary<string, string>> dataList = new List<Dictionary<string, string>>();
int currUser = 0;
for (int i = 0; i < dt.Rows.Count; ++i) for (int i = 0; i < dt.Rows.Count; ++i)
{ {
DataRow row = dt.Rows[i]; DataRow row = dt.Rows[i];
string type = row["FullType"].ToString();
Dictionary<string, string> obj = new Dictionary<string, string>(); Dictionary<string, string> obj = new Dictionary<string, string>();
obj["ColumnType"] = row["ColumnType"].ToString(); obj["ColumnType"] = row["ColumnType"].ToString();
obj["TextSearch"] = row["TextSearch"].ToString(); obj["TextSearch"] = row["TextSearch"].ToString();
obj["ItemID"] = row["ItemID"].ToString(); obj["ItemID"] = row["ItemID"].ToString();
obj["PackageID"] = row["PackageID"].ToString(); obj["PackageID"] = row["PackageID"].ToString();
obj["FullType"] = row["FullType"].ToString(); obj["FullType"] = type;
obj["FullTypeLocalized"] = GetTypeDisplayName(type);
obj["AccountID"] = row["AccountID"].ToString(); obj["AccountID"] = row["AccountID"].ToString();
dataList.Add(obj); if (String.Equals(type, "Users"))
dataList.Insert(currUser++, obj);
else
dataList.Add(obj);
} }
var jsonSerialiser = new JavaScriptSerializer(); var jsonSerialiser = new JavaScriptSerializer();
@ -136,5 +143,14 @@ namespace WebsitePanel.WebPortal
context.Response.Write(json); context.Response.Write(json);
} }
} }
protected const string ModuleName = "WebsitePanel";
protected string GetTypeDisplayName(string type)
{
return PortalUtils.GetSharedLocalizedString(ModuleName, "ServiceItemType." + type)
?? PortalUtils.GetSharedLocalizedString(ModuleName, "UserItemType." + type)
?? type;
}
} }
}; };

View file

@ -186,6 +186,11 @@ namespace WebsitePanel.Portal
{ {
ShowWarningMessage("WrongLogin"); ShowWarningMessage("WrongLogin");
} }
else if (loginStatus == BusinessSuccessCodes.SUCCESS_USER_ONETIMEPASSWORD)
{
// One time password should be changed after login
Response.Redirect(EditUrl("UserID", PanelSecurity.LoggedUserId.ToString(), "change_onetimepassword", "onetimepassword=true"), true);
}
else else
{ {
// redirect by shortcut // redirect by shortcut

View file

@ -30,7 +30,7 @@
{ {
response($.map(data, function (item) { response($.map(data, function (item) {
return { return {
label: item.TextSearch + " [" + item.FullType + "]", label: item.TextSearch + " [" + item.FullTypeLocalized + "]",
code: item code: item
}; };
})); }));

View file

@ -80,6 +80,11 @@ namespace WebsitePanel.Portal
if (!String.IsNullOrEmpty(changePasswordWarningText)) if (!String.IsNullOrEmpty(changePasswordWarningText))
lblChangePasswordWarning.Text = changePasswordWarningText; lblChangePasswordWarning.Text = changePasswordWarningText;
} }
if (PanelRequest.GetBool("onetimepassword"))
{
ShowWarningMessage("USER_SHOULD_CHANGE_ONETIMEPASSWORD");
}
} }
catch (Exception ex) catch (Exception ex)
{ {