DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

What is the right code for DNN Login

Sort:
You are not authorized to post a reply.





New Around Here





    I tried to write my own login module for our platform. And I copied the code of DNN AuthenticationService from the DNN source project. But it didn't work.

    Any one can give me some advice? following code is what I wrote:

    private void LoginUser(string username, string password)

    {

    var status = UserLoginStatus.LOGIN_FAILURE;

     

    var objUser = UserController.ValidateUser(PortalId, username, password,

    "DNN", PortalSettings.PortalName, UserRequestIPAddressController.Instance.GetUserRequestIPAddress(new HttpRequestWrapper(Request)), ref status);

    var authenticated = Null.NullBoolean;

    var message = Null.NullString;

    if (status == UserLoginStatus.LOGIN_USERNOTAPPROVED)

    {

    message = "UserNotAuthorized";

    }

    else

    {

    authenticated = status != UserLoginStatus.LOGIN_FAILURE;

    }

     

    // Raise UserAuthenticated Event

    var eventArgs = new UserAuthenticatedEventArgs(objUser, username, status, "DNN")

    {

    Authenticated = authenticated,

    Message = message,

    RememberMe = false,

    };

    this.OnUserAuthenticated(eventArgs);

    }






    Veteran Member





      I think that we need some additional details.

      First, which version of DNN?

      Second, did you create a new authentication provider, install it in the standard manner, and activate it on your installation? Exactly what did you do?

      And can you provide any additional details that describe "it didn't work." Are there errors in the Admin log? In /portals/_default/logs? Is there any other information on the behavior?

      I have created several different authentication modules. I believe that every one of of them began as a copy of the standard DNN provider, with namespaces, etc. replaced by custom ones. Once that was installed and working correctly (You can enable the new provider and keep the original one. That means you have an working ability to login while you develop), you can proceed to add your custom code.

      So, describe what you have actually done, and perhaps we can provide more helpful suggestions.
      Joe Craig
      DNN MVP
      Patapsco Research Group





      Veteran Member





        You may find this helpful, too, in spite of its age:

        https://www.dnnsoftware.c...hentication-provider
        Joe Craig
        DNN MVP
        Patapsco Research Group





        New Around Here





          Thank you for your answer Joe. According to your suggestion, I should first create an authentication provider before I create the login module. I will try to do it now and thanks for the Link for creating the provider.
          😊
          You are not authorized to post a reply.

          These Forums are dedicated to the discussion of DNN Platform.

          For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

          1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
          2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
          3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
          4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
          5. No Flaming or Trolling.
          6. No Profanity, Racism, or Prejudice.
          7. Site Moderators have the final word on approving / removing a thread or post or comment.
          8. English language posting only, please.

          Would you like to help us?

          Awesome! Simply post in the forums using the link below and we'll get you started.

          Get Involved