Re: [Zope] how to check a user role with data entred by user?

2009-03-08 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 08.03.2009 9:42 Uhr, Lennart Regebro wrote:
> On Sun, Mar 8, 2009 at 08:07, Dvir Bar-lev  wrote:
>> K, ill try to explain in more detail. :)
>> What I want to do is this:
>>
>> I create 2 roles in zope - manager and client for example.
>> I than create 2 users - zoe and don.
>> Zoe has password A and role manager and don has password B and role client.
>> Now I go to the log in page of my site, it has 2 fields - username and 
>> password.
>> What I want to do is this:
>> If the user puts in the fileds zoe and A I want to be able to identify the 
>> user zoe with the role manager
> 
> You already have. You gave Zoe the role "Manager", you say. OK. Done.
> You don't need to do anything more.
> 
> 
> I suspect you still need to explain, not what you are trying to do,
> but what you are trying to achieve. Explain the usecase.

Write a form with two fields username + password, configure the cookie
crumbler in order to intercept both name from the request for
authentication. Within the script called by the form you can check the
roles assigned to the current user and perform the redirection as
needed. This is trivial.

- -aj
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkmzkmsACgkQCJIWIbr9KYw/pwCfUfEQdYig9yIxYfmlm+crPIWQ
NwkAoNGzTfPakrlRmIfUrBCoOjN9rbR5
=2LW/
-END PGP SIGNATURE-
begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:i...@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-08 Thread Dvir Bar-lev
K, here goes, explanation 3 :)

This is what I would like to happen:

A user goes to the site, he see the log in screen that has 2 entry
fields - user name and password.
The user enteres the data and presses the submit button.
Now I want to take what the user entered and see if I have the same user
and password defined in acl_users folder, if so I want to give him the
role that that user in the acl_users folder have.
And than based on that role direct him to the appropriate page

What I don't want is that the zope will pop up his log in window, in
essence I want to do my own authentication, validation and role
assigning.

Ihope this clears up what I want, I thought about using the PAS plugin
but I have no idea how to use it and I was told I can do what I want
without using any plugins at all.

-Original Message-
From: Lennart Regebro [mailto:rege...@gmail.com] 
Sent: Sunday, March 08, 2009 10:42 AM
To: Dvir Bar-lev
Cc: zope@zope.org
Subject: Re: [Zope] how to check a user role with data entred by user?

On Sun, Mar 8, 2009 at 08:07, Dvir Bar-lev  wrote:
> K, ill try to explain in more detail. :)
> What I want to do is this:
>
> I create 2 roles in zope - manager and client for example.
> I than create 2 users - zoe and don.
> Zoe has password A and role manager and don has password B and role
client.
> Now I go to the log in page of my site, it has 2 fields - username and
password.
> What I want to do is this:
> If the user puts in the fileds zoe and A I want to be able to identify
the user zoe with the role manager

You already have. You gave Zoe the role "Manager", you say. OK. Done.
You don't need to do anything more.


I suspect you still need to explain, not what you are trying to do,
but what you are trying to achieve. Explain the usecase.

-- 
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-08 Thread Lennart Regebro
On Sun, Mar 8, 2009 at 08:07, Dvir Bar-lev  wrote:
> K, ill try to explain in more detail. :)
> What I want to do is this:
>
> I create 2 roles in zope - manager and client for example.
> I than create 2 users - zoe and don.
> Zoe has password A and role manager and don has password B and role client.
> Now I go to the log in page of my site, it has 2 fields - username and 
> password.
> What I want to do is this:
> If the user puts in the fileds zoe and A I want to be able to identify the 
> user zoe with the role manager

You already have. You gave Zoe the role "Manager", you say. OK. Done.
You don't need to do anything more.


I suspect you still need to explain, not what you are trying to do,
but what you are trying to achieve. Explain the usecase.

-- 
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-07 Thread Dvir Bar-lev
K, ill try to explain in more detail. :)
What I want to do is this:

I create 2 roles in zope - manager and client for example.
I than create 2 users - zoe and don.
Zoe has password A and role manager and don has password B and role client.
Now I go to the log in page of my site, it has 2 fields - username and password.
What I want to do is this:
If the user puts in the fileds zoe and A I want to be able to identify the user 
zoe with the role manager
And if he puts don and B I want to identify him with the role client, anything 
else he puts in I want to consider him as an anonymus user.

I hope this clears things up :)

-Original Message-
From: Lennart Regebro [mailto:rege...@gmail.com] 
Sent: Thursday, March 05, 2009 11:33 PM
To: Dvir Bar-lev
Cc: zope@zope.org
Subject: Re: [Zope] how to check a user role with data entred by user?

On Thu, Mar 5, 2009 at 09:21, Dvir Bar-lev  wrote:
> What I did was this, I created a folder in the ZMI and there I created a
> user folder(acl_users), in the user folder I defined  2 new roles.
>
> Now, I have a log in form where the user fills out user name and password, I
> want to check if the data he entered matches 1  of the roles I defined in
> the ZMI . I can't find any info or example how to do it, not on the web nor
> in the documentation.

This is a classic case of you not telling is what you want to do.
Why do you want to check if the data he enters matches on of the roles?

You do that with

 if entered_data in (role1, role2):

which I suspect isn't what you are asking at all. :) Tell us what you
are trying to achieve.

-- 
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-05 Thread Lennart Regebro
On Thu, Mar 5, 2009 at 09:21, Dvir Bar-lev  wrote:
> What I did was this, I created a folder in the ZMI and there I created a
> user folder(acl_users), in the user folder I defined  2 new roles.
>
> Now, I have a log in form where the user fills out user name and password, I
> want to check if the data he entered matches 1  of the roles I defined in
> the ZMI . I can’t find any info or example how to do it, not on the web nor
> in the documentation.

This is a classic case of you not telling is what you want to do.
Why do you want to check if the data he enters matches on of the roles?

You do that with

 if entered_data in (role1, role2):

which I suspect isn't what you are asking at all. :) Tell us what you
are trying to achieve.

-- 
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-05 Thread Andrew Milton
+---[ Dvir Bar-lev ]--
| First tx for the reply Andrew.
| How do I check that the password that was entered is the correct one for
| that role than?
| As it is presented in the reply the password of the role and the one
| that the user entered aren't any consideration at all

Right you didn't ask about logging them in :-)
You asked about checking the role :-)

You can't directly access the password in the user object from a python
script because it's protected (by virtue of being named '__', and the
getPassword method is named '_getPassword')

Logging them in from a form, without using a user folder product that
caters to that, or a PAS plugin, or using the Cookie Crumbler product,
is a little difficult to do and is probably not worth the effort given
the number of people who have already solved this problem for you.

Since you're new, I would look into PAS (Pluggable Auth Source) plugins
since it seems you want to do your own authentication.

-- 
Andrew Milton
a...@theinternet.com.au
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-05 Thread Dvir Bar-lev
First tx for the reply Andrew.
How do I check that the password that was entered is the correct one for
that role than?
As it is presented in the reply the password of the role and the one
that the user entered aren't any consideration at all

-Original Message-
From: Andrew Milton [mailto:a...@theinternet.com.au] 
Sent: Thursday, March 05, 2009 10:29 AM
To: Dvir Bar-lev
Cc: zope@zope.org
Subject: Re: [Zope] how to check a user role with data entred by user?

+---[ Dvir Bar-lev ]--
| Hi all.
| 
|  
| 
| I have a question and I hope someone can help me out.
| 
| I?m new to zope and the all web thing, I?m using zope2.
| 
|  
| 
| What I did was this, I created a folder in the ZMI and there I created
a user
| folder(acl_users), in the user folder I defined  2 new roles.
| 
| Now, I have a log in form where the user fills out user name and
password, I
| want to check if the data he entered matches 1  of the roles I defined
in the
| ZMI . I can?t find any info or example how to do it, not on the web
nor in the
| documentation.
| 
|  
| 
| I would appreciate any help on the matter.

in a python script;

user = context.acl_users.getUser(theUserNameTheUserEnteredInTheForm)

if user.has_role(['Role1', 'Role2']):
  # User has role log them in I suppose
else:
  # Bad user! Bad!



-- 
Andrew Milton
a...@theinternet.com.au
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how to check a user role with data entred by user?

2009-03-05 Thread Andrew Milton
+---[ Dvir Bar-lev ]--
| Hi all.
| 
|  
| 
| I have a question and I hope someone can help me out.
| 
| I?m new to zope and the all web thing, I?m using zope2.
| 
|  
| 
| What I did was this, I created a folder in the ZMI and there I created a user
| folder(acl_users), in the user folder I defined  2 new roles.
| 
| Now, I have a log in form where the user fills out user name and password, I
| want to check if the data he entered matches 1  of the roles I defined in the
| ZMI . I can?t find any info or example how to do it, not on the web nor in the
| documentation.
| 
|  
| 
| I would appreciate any help on the matter.

in a python script;

user = context.acl_users.getUser(theUserNameTheUserEnteredInTheForm)

if user.has_role(['Role1', 'Role2']):
  # User has role log them in I suppose
else:
  # Bad user! Bad!



-- 
Andrew Milton
a...@theinternet.com.au
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )