开发者

First and last event in dotnetnuke application

I have to add some logic when user logs in and logs out of dnn application. But I don't want to change 开发者_运维技巧login module or anything in dnn. Is there any event that I can catch?


You can tell DNN to redirect to a special page upon Login and Logout.

Visit Admin -> User Accounts --> User Settings

First and last event in dotnetnuke application

You would want to redirect them to a "LoginSuccess.aspx" page that has a custom module that you built on it that does the following:

  • Executes custom logic upon user login
  • Redirects the user to a useful page

You can do the same for user logout. You can use the same page and same module for logout as you do with login, if you wish -- you will just want to check to see if the current user is authenticated or not to determine which logic to perform and which page to redirect them to.

Summary of Steps for a dedicated LoginSuccess Page

  1. Create a DNN Page called LoginSuccess.aspx
  2. Edit Page Settings: Do not show in menu, sitemap priority 0, viewable by authenticated users only
  3. Create a Custom DNN Module that performs your custom logic upon User Login
  4. Drop module onto this page
  5. Make sure to redirect user somewhere after your custom logic is done processing

Rinse and repeat for Logout

I do not know if this method allows you to redirect the user to the last page that they were on before logging in / logging out. If I had to guess, I would guess that you lose this functionality.

If you are having trouble upon user logout determining who just logged out, this can be solved by saving the UserID into the Session State upon user login (In your Custom Login DNN Module above). Something like: Session("UserID") = 'current user id'

Dealing with Special Cases

Make sure to restrict these "special pages" containing these login/logout processing module(s) to do the following:

  • Do not include in navigation
  • Sitemap Priority of 0

And you will probably want your "logout processor" module to do the following if it is accessed manually by a maliciuos/annoying/lost user or bot (Example: User navigates straight to MySite/ProcessLogout.aspx):

  • If your Logout Module is accessed but Session("UserID") is nothing, then redirect to the site's home page and do not process your custom user logout logic.

I believe this answers your question, but perhaps not the way that you had hoped. I did not find an event you could simply handle without modifying the DNN core like @capdragon suggested. If you go that method, be sure to comment it extremely well and modify the code in such a way that it should be a matter of copy-pasting in order to deploy to future versions of DNN (every time you upgrade DNN, for example)


I would modify the cmdLogin_Click() and add a call to your class.

I've done it in the past. that page does not change often at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜