Custom Login in DotnetNuke (DNN)

Custom Login in DotnetNuke (DNN)

UserInfo _user = new UserInfo(); // Dnn Inbuilt USer CLass
private void GetUser()
{

string userName=txtEmail.Text.Trim();

//Getting User detail from username and placing user detail in UserInfo object for further use

_user = DotNetNuke.Entities.Users.UserController.GetUserByName(this.PortalId, userName);

}
private void AutoLogin()
{
GetUser();
if (txtPassword.Text != “” && _user != null)
{

//LoginType is default property in dnn
string prfileName = _user.Profile.GetPropertyValue(“LoginType”);
var message = Null.NullString;

var loginStatus = UserLoginStatus.LOGIN_FAILURE;
var objUser = UserController.ValidateUser(PortalId, txtEmail.Text, txtPassword.Text, “DNN”, “”, PortalSettings.PortalName, ref loginStatus);
if (objUser != null)
{

UserInfo objUserInfo = UserController.GetUserByName(PortalId, txtEmail.Text.Trim());

UserController.UserLogin(PortalId, objUserInfo, PortalSettings.PortalName, Request.UserHostAddress, false);// This line showing the status of logined user

//Using tab controller for show page for logiggned user.
TabController objTab = new TabController();
TabInfo objTabInfo = new TabInfo();
objTabInfo = objTab.GetTabByName(“lifetime”, this.PortalId);//lifetime is Tab name

//From above we get tab Id after that we can redirect to that tab

int tabId = objTabInfo.TabID;

Response.Redirect(Globals.NavigateURL(tabId));

}
}

}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply