]> sipb.mit.edu Git - ikiwiki.git/blob - doc/forum/appear_if_you_are_login_or_not_in_a_page.mdwn
(no commit message)
[ikiwiki.git] / doc / forum / appear_if_you_are_login_or_not_in_a_page.mdwn
1 Hi,
2
3 Can you give me a hint for showing if one user is logged or not. If user is logged, then I want to display the user name, as wikipedia or dokuwiki for example.
4 Regards,
5 Xan.
6
7 > ikiwiki doesn't serve pages, so this can't be done inside ikiwiki.
8 > For certain kinds of authentication it might be possible anyway.
9 > For instance, if you're using [[plugins/httpauth]] exclusively and
10 > your server has PHP, you could put `<?php print("$REMOTE_USER");
11 > ?>` in all the relevant ikiwiki [[templates]] and arrange for the
12 > generated HTML pages to get run through the PHP interpreter. The trick
13 > would work differently with other [[plugins/type/auth]] plugins,
14 > if at all. --[[Schmonz]]
15
16 >> Thanks a lot, Xan.
17
18 >>> Another possible trick would be to use some Javascript to make a
19 >>> "who am I?" AJAX request to the CGI (the CGI would receive the
20 >>> session cookie, if any, and be able to answer). Obviously, this
21 >>> wouldn't work for users who've disabled Javascript, but since it's
22 >>> non-essential, that's not so bad. You'd need to
23 >>> [[write_a_plugin|plugins/write]] to add a suitable CGI action,
24 >>> perhaps ?do=whoami, and insert the Javascript. --[[smcv]]
25
26 >>>> It's an idea, but you're trading off a serious speed hit for a very
27 >>>> minor thing. --[[Joey]]
28
29 >>>> Cool idea. A similar trick (I first saw it
30 >>>> [here](http://www.peej.co.uk/articles/http-auth-with-html-forms.html))
31 >>>> could be used to provide a [[plugins/passwordauth]]-like login form
32 >>>> for [[plugins/httpauth]]. --[[Schmonz]]
33
34 >>>>> I always assumed the entire reason someone might want to use the
35 >>>>> httpauth plugin is to avoid nasty site-specific login forms..
36 >>>>> --[[Joey]]