/ Published in: C#
This is another login method, a little more robust
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
protected void lnkLogin_Click(object sender, EventArgs e) { string AuthType = "DNN"; DotNetNuke.Security.Membership.UserLoginStatus status = new DotNetNuke.Security.Membership.UserLoginStatus(); DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.ValidateUser(PortalId, txtUser.Text, txtPassword.Text, AuthType, "", PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status); bool success = true; switch (status) { case DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS: UserInfo.Membership.Password = txtPassword.Text; UserInfo.Username = txtUser.Text; DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true); break; case DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER: UserInfo.Membership.Password = txtPassword.Text; UserInfo.Username = txtUser.Text; DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true); break; default: //showerror success = false; break; } if (success) { Response.Redirect(Request.RawUrl); } }