简体   繁体   English

如何在 DNN 中使用自定义用户身份验证

[英]how to work with Custom UserAuthantication in DNN

I have created new login skin object which contain a single hyperlink.我创建了包含单个超链接的新登录皮肤对象。 this skinobject is placed on another custom sking object.此皮肤对象放置在另一个自定义皮肤对象上。 When this login hyperlink is clicked i open a popup a div, this div contains the DNN's built in login control placed in Desktopmodules/Admin/Autanticationservice/.单击此登录超链接时,我会打开一个弹出窗口,该 div 包含 DNN 的内置登录控件,位于 Desktopmodules/Admin/Autanticationservice/。 Now when login module pops up and i click on login button, this hits to the login_clicked event of the DNN's Login module.现在,当登录模块弹出并单击登录按钮时,这会触发 DNN 登录模块的 login_clicked 事件。 Here i see through debugging that user passes the authantication but inside this method on the last line "OnUserAuthenticated(args)" does not being called...???Why???在这里,我通过调试看到用户通过了身份验证,但在最后一行的“OnUserAuthenticated(args)”方法内部没有被调用......???为什么??? any ideas..???有任何想法吗..???

I had this one, too, haven't figured out how to fix the real problem, but you can get around it by replacing:我也有这个,还没有想出如何解决真正的问题,但你可以通过替换来解决它:

UserController.ValidateUser(PortalId, txtUsername.Value, txtPassword.Value, "DNN", string.Empty, PortalSettings.PortalName, IPAddress, ref loginStatus);

with

UserController.UserLogin(PortalSettings.PortalId, txtUsername.Value, txtPassword.Value, string.Empty, PortalSettings.PortalName, IPAddress, ref loginStatus, false);

It will at least log you in then, but you will have to deal with redirecting yourself.它至少会让你登录,但你必须自己处理重定向。

It is a hack and I'm not happy with it, but hopefully this helps someone else.这是一个黑客行为,我对此并不满意,但希望这对其他人有所帮助。

I had the same issue, looked long and hard and eventually had to download the full source and follow through the code for login in the full dnn app:我遇到了同样的问题,看起来又长又难,最终不得不下载完整的源代码并按照代码在完整的 dnn 应用程序中登录:

Once I added the following I could successfully authenticate a user:添加以下内容后,我可以成功验证用户身份:

        // from above
        UserController.UserLogin(PortalSettings.PortalId, txtUsername.Value, txtPassword.Value, string.Empty, PortalSettings.PortalName, IPAddress, ref loginStatus, false);
        // login and auth with DNN
        var existingUserEventArgs = new UserAuthenticatedEventArgs(loginUser, loginUser.Username, loginStatus, "DNN");
        existingUserEventArgs.Authenticated = true;
        EventManager.Instance.OnUserAuthenticated(new UserEventArgs { User = loginUser });
        // success - redirect - or what ever

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM