Dokuwiki Link to login page

1.8k views Asked by At

I use the dokuwiki and the users need to login for viewing several pages. When he is not logged in, he gets the following error message page:

enter image description here

As you can see I already tried to add a link to the Login page. I would like to keep the initial page requested in the link, but add the do=login to redirect to the login page.

[[#?do=login|Perhaps you forgot to login?]]

How can I create a link to the same page but showing the login page instead of the access denied?

The page is the inc/lang/en/denied.txt

2

There are 2 answers

0
Subharanjan On BEST ANSWER

Have you tried with this plugin "showlogin" to display the login form appended within this page. https://www.dokuwiki.org/plugin:showlogin

Basically this is the code which stop showing the default denied page which contains text message and instead login form.

class action_plugin_showlogin extends DokuWiki_Action_Plugin {

    /**
     * Register its handlers with the dokuwiki's event controller
     */
    public function register(Doku_Event_Handler &$controller) {

      # TPL_CONTENT_DISPLAY is called before and after content of wikipage is written to output buffer
       $controller->register_hook('TPL_CONTENT_DISPLAY', 'BEFORE', $this, 'handle_tpl_content_display');

    }

    /**
     * Handle the event
     */ 
    public function handle_tpl_content_display(Doku_Event &$event, $param) {
      global $ACT;

      # If user is not logged in and access to page is denied, show login form
      if (($ACT == 'denied') && (! $_SERVER['REMOTE_USER'])) {
    $event->preventDefault(); // prevent "Access denied" page from showing
    html_login(); // show login dialog instead
      }
      # .. or show regular access denied page
    }

}
0
selfthinker On

The given accepted answer is the better solution for your issue, but to answer your original question:

You can use the interwiki link "this>" to link to anything from the wiki's root. So, for your example [[this>?do=login|Perhaps you forgot to login?]] would do the trick.

If you do that, please keep also in mind that the core's language files would be overwritten with the next update. So, best change them by adding a copy to your conf folder.