User roles

8 views
Skip to first unread message

whatever

unread,
Sep 23, 2010, 9:10:13 AM9/23/10
to TiddlyWiki
Hi!
I was wondering whether limiting user access by roles was possible.
For example, I have three roles: Admin, PowerUser and User. I want the
Users to only be able to access tiddlers tagged with their names. The
PowerUsers can access additional tiddlers and Admin can access all
tiddlers. Obviously any tiddly-savy person can get around the
restrictions, but my users aren't tiddly-savy. As Eric put it in his
TiddlerPasswordPlugin, I want the roles to be "latches", not "locks",
the intent is to prevent accidental opening. Is this possible?

w

Tobias Beer

unread,
Sep 23, 2010, 1:55:42 PM9/23/10
to TiddlyWiki
Hi whatever,

If all you do is authenticate by setting a UserName, then here's
something (I just created) for you...

http://tobibeer.tiddlyspace.com/#SimpleRoles

Cheers, Tobias.

whatever

unread,
Sep 23, 2010, 4:49:39 PM9/23/10
to TiddlyWiki
You're awesome!
However, I do have some questions. Is the EvalifyPlugin required?
Because I keep getting errors. Also, I'm not clear on how to assign
roles. Do I need to use something like <<option simpleUserRole>>? And
where do I put that? And how do I define, to which tiddlers a User has
access as opposed to an Admin or PowerUser? Do I need to create
tiddlers with usernames?

w
Message has been deleted

Tobias Beer

unread,
Sep 23, 2010, 7:51:25 PM9/23/10
to TiddlyWiki
Hi whatever,

Some answers...
1) Is the EvalifyPlugin required?
No, not unless you want to display the user role on TiddlySpace as I
did. In a Non-TiddlySpace-TiddlyWiki you can use the tiddler macro
like so...
Tiddler:GetRole
<<tiddler GetRole##OUT with {{window.simpleRoles[0];}}>>/%
!OUT
$1
!END%/

2) Because I keep getting errors.
Where, when, which?

3) Also, I'm not clear on how to assign roles.
Simply put the user-names into the corresponding sections of your
SimpleRolesConfig tiddler.

4) Do I need to use something like <<option simpleUserRole>>? And
where do I put that?
Of course not, or do you want your users to choose their own role?
Again, you assign roles to users in SimpleRolesConfig.

5) And how do I define, to which tiddlers a User has access as opposed
to an Admin or PowerUser?
You would have to use conditional templating as in the example. You
could also define different restrictions for search with
YourSearchPlugin or GotoPlugin... and then include those
conditionally.

As an example using HideWhenPlugin...
<span macro="showWhen window.simpleRoles.contains('Admin')">
<span id='mainMenu' refresh='content' tiddler='MainMenuAdmin'></span>
</span>
<span macro="else">
<span id='mainMenu' refresh='content' tiddler='MainMenu'></span>
</span>

The same way you could hide the entire tiddler content.

6) Do I need to create tiddlers with usernames?
Not when it comes to roles, no.

You could, however, tag tiddlers with a role - like "Admin" - and then
use a conditional statement to check if the role is assigned to the
current tiddler AND the current user.

Cheers, Tobias.

whatever

unread,
Sep 24, 2010, 3:47:43 AM9/24/10
to TiddlyWiki
Hi!

1. Good to know.

2. Evalify errors:
in tiddler Evalify:
Error while executing macro <<evalify>>: SyntaxError: unterminated
string literal
and
Error while executing macro <<evalify>>: SyntaxError: missing ;
before statement

In tiddler SimpleRoles:
Error while executing macro <<evalify>>: ReferenceError: User1 is
not defined
and
Error while executing macro <<evalify>>: ReferenceError: Guest is
not defined

3. It was late last night and I wasn't thinking clearly, even though I
had already done exactly that. :D

4. Ok, I'm clear on that.

5. Well, the funny thing is that I had read that and then I spent the
entire night practically dreaming that I'd found an easier way to do
it without your plugin, but when I read your answer this morning, I
realized that I can do it WITH your plugin. :D Also, this example is a
bit clearer because of the "else" macro.

6. A useful thing.

Thanx.

w

whatever

unread,
Sep 25, 2010, 1:54:35 PM9/25/10
to TiddlyWiki
Anyway, the "else" macro threw an error, since it doesn't exist, but I
simply replaced it with <span macro="showWhen !
window.simpleRoles.contains('Admin')">.
It works great! :D
Thanx.
w
Reply all
Reply to author
Forward
0 new messages