How do I change the messaging on the sitecore login page?

I need to change the default messaging on the Sitecore login page (www.example.com/sitecore/login). It looks like this message comes from the Sitecore.sitecore.login.Login_LoginError method in Sitecore.Client.dll . However, this method is private, which means I'm stuck:

  • I cannot override the method because it is closed.
  • I cannot unsubscribe the handler from the LoginError event, because the handler is private.
  • I cannot add my event handler to change the text, because I cannot guarantee the order in which the handlers are called.

As I see it, I have two options, no good:

  • Write your own login page class from scratch, using the existing code as close as possible, but with the members I need.
  • Use reflection to find a private handler so I can unsubscribe from this event.

I don’t want to do that either. Is there a better way?

+4
source share
1 answer

The need to override this behavior in Sitecore is common. Reflector is your best friend. Find the class in the code for the login page and find it. In most cases, you do not need to try to recreate it by cutting and pasting a lot of code. You can simply create a new class of the same type that inherits the input class, and then simply override the one method in which the action takes place. When finished, modify the .aspx file to refer to a new class that will be built into your own assembly instead of the Sitecore.dll file.

However, sometimes, if you just want to change something cosmetic, like an error message (which really does not require any logic in the background), you may be much better served by the one-time part of javascript on the page, hiding the default error message, when it appears, and displays its own custom div style and message. Do everything with the least amount of moving parts.

+1
source

Source: https://habr.com/ru/post/1501991/


All Articles