Tharindu Madushanka wrote:
> Hi,
> I have defined the class UserLoginEvent in package
> org.xwiki.observation.event
> 
> Then in order to be notified I think we could change the LoginSubmitAction
> class render() it the message is null we could notify the listener of a
> successful login.
> 
> 
> Index: xwiki-core/src/main/java/com/xpn/xwiki/web/LoginSubmitAction.java
> ===================================================================
> --- xwiki-core/src/main/java/com/xpn/xwiki/web/LoginSubmitAction.java
> (revision 19222)
> +++ xwiki-core/src/main/java/com/xpn/xwiki/web/LoginSubmitAction.java
> (working copy)
> @@ -22,14 +22,25 @@
> 
>  import javax.servlet.http.HttpServletResponse;
> 
> +import org.xwiki.observation.ObservationManager;
> +import org.xwiki.observation.event.UserLoginEvent;
> +
>  import com.xpn.xwiki.XWikiContext;
>  import com.xpn.xwiki.XWikiException;
> 
> -public class LoginSubmitAction extends XWikiAction {
> -    public String render(XWikiContext context) throws XWikiException {
> -        String msg = (String)context.get("message");
> -        if(msg != null && !msg.trim().equals("")) {
> +public class LoginSubmitAction extends XWikiAction
> +{
> +    public String render(XWikiContext context) throws XWikiException
> +    {
> +        String msg = (String) context.get("message");
> +        if (msg != null && !msg.trim().equals("")) {
> 
> context.getResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
> +        } else {
> +            ObservationManager om = (ObservationManager)
> Utils.getComponent(ObservationManager.class);
> +            if (om != null) {
> +                om.notify(new UserLoginEvent(context.getDoc().getWikiName()
> + ":" + context.getDoc().getFullName()),

The login event should contain the name of the user, not the document. 
Try context.getUser().

> +                    context.getDoc(), context);
> +            }
>          }
>          return "login";
>      }

I need to test this to see if it is right. I guess it should be, but I'm 
not sure.

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to