HI there,
I am trying to make a custom login for my skin. I coped the DNN\DesktopModules\Admin\Authentication\Login.ascx and put the code behind in a separated dll so I can debug that easily and edited it. I manage to make it work for normal users but when a supper user (host) ties to log in I get an error at :
AuthenticationController.AddUserAuthentication(objUser.UserID, AuthenticationType, UserToken);
error :
An exception of type 'System.Data.SqlClient.SqlException' occurred in PetaPoco.dll but was not handled in user code
Additional information: Cannot insert duplicate key row in object 'dbo.UserAuthentication' with unique index 'IX_UserAuthentication'. The duplicate key value is (1, ).
I understand that for some reason this is not the way to handle supper user but how should I handle that then ?
Here is my code :
protected void CostomLogin_Click(object sender, EventArgs e)
{
UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
UserInfo objUser = UserController.ValidateUser(PortalId,
tbEmail.Text,
tbPassword.Text,
"DNN",
"",
PortalSettings.PortalName,
AuthenticationLoginBase.GetIPAddress(),
ref loginStatus);
if (loginStatus == UserLoginStatus.LOGIN_SUCCESS || loginStatus == UserLoginStatus.LOGIN_SUPERUSER)
{
AuthenticationController.AddUserAuthentication(objUser.UserID, AuthenticationType, UserToken);
if (objUser != null)
{
UpdateProfile(objUser, true);
}
ValidateUser(objUser, true);
}