[pmwiki-users] Checking for logged-in user

Sandy sandy at onebit.ca
Thu Feb 26 08:17:27 CST 2009


DaveG wrote:
>  From a wiki page, using the default PmWiki security AuthUser, what is 
> the correct way to determine if someone is logged in (ie, to show a 
> Logout link), and is not logged in (ie, to show a login link).
> 
> Can someone confirm that this is the correct method (which checks for a 
> password only, not password validity): (:if !enabled authpw:)
> 

Checking older posts I can shed some light on.

I use this in my Site.SideBar . I remember reading copying it from 
somewhere I trusted.

(:if authid:)
User: {$AuthId}
[[{*$FullName}?action=logout|Logout]]\\
(:if auth edit:)
[[{*$FullName}?action=edit|Edit]]\\
(:if auth admin:)
[[{*$FullName}?action=attr|Page Password]]\\
[[Site.Site|Site Admin]]
(:if !authid:)
[[{*$FullName}?action=login|Login]]
(:if:)

Remember, (:if:) doesn't nest, so the above says:

If you have an ID, say User is George, and give logout link.

If you have edit permission, give link to edit.

If you have admin permission, give link to attr page and a page of 
useful admin info.

If you have no ID, give login link.

A quick test just now shows that logging in with the admin password, but 
not the admin ID, doesn't give an login error page, but neither does it 
give you any permissions. Even adding ?action=edit to the URL doesn't 
work -- it asks me to log in.

Sandy




More information about the pmwiki-users mailing list