I have developed my own custome registration module. Data is going user table and other table correctly. But when user register , user not login automatically.
I ll put code to here. How can i adjust this code to login automatically
try
{
// Only attempt a save/update if all form fields on the page are valid
lblError.Text = "one";
if ( Page.IsValid == true)
{
lblError.Text = "2";
// update the user record in the database
UserController objUsers = new UserController();
UserInfo ObjUser = default(UserInfo);
if (Id == -1)
{
lblError.Text = "3";
ObjUser = new UserInfo();
if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId) {
ObjUser.PortalID = -1;
ObjUser.IsSuperUser = true;
}
else {
ObjUser.PortalID = PortalId;
lblError.Text = "4";
}
ObjUser.Membership.Username = txtUserName.Text ;
ObjUser.Username = txtUserName.Text;
ObjUser.Profile.FirstName = txtFname.Text ;
ObjUser.Profile.LastName = txtLName.Text ;
ObjUser.Membership.Email = txtUserName.Text;
ObjUser.AffiliateID = Null.NullInteger;
ObjUser.Membership.Password = txtPAssword.Text ;
Id = objUsers.AddUser(ObjUser, true);
ObjUser.UserID = Id;
PortalSecurity objPortalSecurity = new PortalSecurity();
objPortalSecurity.UserLogin(txtUserName.Text, txtPAssword.Text, this.PortalId, this.PortalAlias,this.
// UserCreateStatus createStatus = UserController.CreateUser(ref ObjUser);
lblError.Text = ObjUser.UserID.ToString();
//lblError.Text = "5";
if (Id >= 0)
{
DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
objEventLog.AddLog(ObjUser, PortalSettings, UserId, txtUserName.Text , DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED);
Mail.SendMail(PortalSettings.Email, txtUserName.Text , "", DotNetNuke.Services.Localization.Localization.GetSystemMessage(ObjUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_SUBJECT", ObjUser), DotNetNuke.Services.Localization.Localization.GetSystemMessage(ObjUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_BODY", ObjUser), "", "", "", "", "",
"");
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "filter=" + txtFname.Text.Substring(0,1)), true);
}
// registration error
else {
//AspNetSecurity.MembershipCreateStatus UserRegistrationStatus = default(AspNetSecurity.MembershipCreateStatus);
//UserRegistrationStatus = (AspNetSecurity.MembershipCreateStatus)UserId * -1;
//UserController objUserController = new UserController();
//lblMessage.Text = objUserController.GetRegistrationStatus(UserRegistrationStatus);
}
}
else {
// if activating an account, send notification
ObjUser = objUsers.GetUser(PortalId, Id);
if ((ObjUser != null))
{
//if (chkAuthorized.Checked) {
// //if (ObjUser.Membership.Approved != chkAuthorized.Checked) {
// // Mail.SendMail(PortalSettings.Email, userControl.Email, "", Services.Localization.Localization.GetSystemMessage(ObjUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_SUBJECT", ObjUser), Services.Localization.Localization.GetSystemMessage(ObjUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_BODY", ObjUser), "", "", "", "", "",
// // "");
// //}
//}
//update the user
ObjUser.Profile.FirstName = txtFname.Text ;
ObjUser.Profile.LastName = txtLName.Text ;
objUsers.UpdateUser(ObjUser);
}
// Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", (!string.IsNullOrEmpty(Request.QueryString["filter"]) ? "filter=" + Request.QueryString["filter"] : "").ToString), true);
}
}
}
//Module failed to load
catch (Exception exc) {
lblError.Text = exc.ToString();
}