Gossamer Forum
Home : Products : DBMan : Customization :

Need Help with This......

(Page 1 of 3)
> >
Quote Reply
Need Help with This......
I have a membership database and I am wanting to set it up to allow those who register to see the short view (list of registered names) - however in order to view the Long Record (Names/info) you must be granted member access.

Has anyone came up with a way to do this?
--------------------------
donm
Quote Reply
Re: Need Help with This...... In reply to
This would require another type of permission, if I'm understanding you correctly. I remember trying that about a year (or more) ago and I couldn't get it to work.

We could try it again, if you want to go through it.


------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
I would really like to try and get this to work if you have some time and wouldn't mind trying to walk me through it.

-------------------------
donm
Quote Reply
Re: Need Help with This...... In reply to
Okey-dokey. I'm going to have to get my brain set for this, so I'll start on it after I've had some sleep.

My suggestion is that you copy all of your files and put the copies in a new directory on your site. You'll also have to adjust the .cfg file a little. I just want to make sure that nothing gets corrupted in your files as we're working on this. I know your database is up and running and we wouldn't want anything to happen to it. Smile


------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
OK Carol - no problem. Get as much rest as you need ! :-)

I already have the files in a different directory and ready to go.

Thanks alot for your help !
----------------------------
donm
Quote Reply
Re: Need Help with This...... In reply to
Okay. We're gonna have to take this in small steps and test each one out as we go.

First, replace your .pass file with the following:

Code:
# UserID : Password : View : Add : Del : Mod: Member:Admin
admin:A.f0Kvdiyy8q2:1:1:1:1:1:1
author:zs047RckAhJH6:1:1:1:1:1:0
guest:ZX9XTlIfPvdGE:1:0:0:0:0:0

Change the "guest" permissions to match the permissions you want to give to registered users. Notice that there is an extra field in there from the original, just before the admin. That is the "member" permission.

In $auth.pl, sub check_password, change

Code:
my ($view, $add, $mod, $del, $admin);

to

Code:
my ($view, $add, $mod, $del, $mem, $admin);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin) = split (/:/, $pass);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin) = split (/:/, $pass);

and change

Code:
return ('ok', $db_uid, $view, $add, $del, $mod, $admin);

to

Code:
return ('ok', $db_uid, $view, $add, $del, $mod, $mem, $admin);

In db.cgi, sub main, change

Code:
($status, $uid, $per_view, $per_add, $per_del, $per_mod, $per_admin)
= &auth_check_password; # Authenticate User, get permissions and userid.

to

Code:
($status, $uid, $per_view, $per_add, $per_del, $per_mod, $per_mem, $per_admin)
= &auth_check_password; # Authenticate User, get permissions and userid.

In html.pl, sub html_home add a print statment somewhere on the page where you will be able to see it

Code:
print "Member -- $per_mem";

Upload the files and login with each of the usernames. You should get the following:

When logged on as admin:
Member -- 1

When logged on as author:
Member -- 1

When logged on as guest:
Member -- 0

(It's possible when you log on as guest that you will get

Member --

but that's okay, too.)

Lemme know what happens. Smile



------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
Ok Carol - that worked out just fine. I receive the following:

admin:
Member -- 1

author:
Member -- 1

guest:
Member -- 0

Next step? :-)

-----------------
donm
Quote Reply
Re: Need Help with This...... In reply to
Excellent! Now to apply the permissions to new signups.

In your .cfg file, change the

@auth_default_permissions

to

(1,0,0,0,0,0)

(Basicly, we're just adding a permission level here. Keep what you have, but add another ,0 to the end.)

Same thing with

@auth_signup_permissions

since those who just sign up online will not be considered members.

You're using the secure password lookup, right? (Or at least one of the lookup mods that includes the email address in the .pass file.) If so, in db.cgi, sub signup, change

Code:
my ($message,$userid, $pw, $view, $add, $del, $mod, $admin, $email, $password);

to

Code:
my ($message,$userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email, $password);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $pass);

If you're not using a password lookup mod (and for those who might be following along who aren't), you won't have to change anything in sub signup.

Now upload your .cfg file and your db.cgi file. Go to the login form and sign up for an account. Log in with the new username and password and see what you get. It should be

Member -- 0

or

Member --

Next, download the .pass file and change the permission to 1 for the new user. Upload the .pass file and log in again as the new user. You should get

Member -- 1

The next step will be changing permissions through the admin display. Smile




------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
Ok ... everything is still working just as it should.

(oh and BTW - yes, I am using the Secure Password Lookup)

Next Step :-)

-----------------
donm

[This message has been edited by donm (edited April 09, 2000).]
Quote Reply
Re: Need Help with This...... In reply to
This is going great! I wonder why I couldn't get it to work before.

For anyone that's reading along who does not have the secure password lookup mod installed, the next section will be different for you. If you need the code for the regular "non-lookup" script and can't figure it out from readin this, just ask. Smile

In db.cgi, sub admin_display

change

Code:
print PASS "$in{'new_username'}:$encrypted:$in{'per_view'}:$in{'per_add'}:$in{'per_del'}:$in{'per_mod'}:$in{'per_admin'}:$in{'email'}\n";

to

Code:
print PASS "$in{'new_username'}:$encrypted:$in{'per_view'}:$in{'per_add'}:$in{'per_del'}:$in{'per_mod'}:$in{'per_mem'}:$in{'per_admin'}:$in{'email'}\n" ;

(This line appears twice -- once when creating a user and once when updating a user. Be sure to change it in both places.)

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $pass);

and change

Code:
$perm = qq|
View <input type=checkbox name="per_view" value="1" |; ($data[2] and $perm .= "CHECKED"); $perm .= qq|>
Add <input type=checkbox name="per_add" value="1" |; ($data[3] and $perm .= "CHECKED"); $perm .= qq|>
Delete <input type=checkbox name="per_del" value="1" |; ($data[4] and $perm .= "CHECKED"); $perm .= qq|>
Modify <input type=checkbox name="per_mod" value="1" |; ($data[5] and $perm .= "CHECKED"); $perm .= qq|>
Admin <input type=checkbox name="per_admin" value="1" |; ($data[6] and $perm .= "CHECKED"); $perm .= qq|>|;

to

Code:
$perm = qq|
View <input type=checkbox name="per_view" value="1" |; ($data[2] and $perm .= "CHECKED"); $perm .= qq|>
Add <input type=checkbox name="per_add" value="1" |; ($data[3] and $perm .= "CHECKED"); $perm .= qq|>
Delete <input type=checkbox name="per_del" value="1" |; ($data[4] and $perm .= "CHECKED"); $perm .= qq|>
Modify <input type=checkbox name="per_mod" value="1" |; ($data[5] and $perm .= "CHECKED"); $perm .= qq|>
Member <input type=checkbox name="per_mem" value="1" |; ($data[6] and $perm .= "CHECKED"); $perm .= qq|>
Admin <input type=checkbox name="per_admin" value="1" |; ($data[7] and $perm .= "CHECKED"); $perm .= qq|>|;

and change

[I seem to have left out something the first time around]

Code:
# Build the permissions list if we haven't inquired in someone.
if (!$perm) {
$perm = qq|
View <input type=checkbox name="per_view" value="1" |; ($auth_default_perm[0] and $perm .= "CHECKED"); $perm .= qq|>
Add <input type=checkbox name="per_add" value="1" |; ($auth_default_perm[1] and $perm .= "CHECKED"); $perm .= qq|>
Delete <input type=checkbox name="per_del" value="1" |; ($auth_default_perm[2] and $perm .= "CHECKED"); $perm .= qq|>
Modify <input type=checkbox name="per_mod" value="1" |; ($auth_default_perm[3] and $perm .= "CHECKED"); $perm .= qq|>
Admin <input type=checkbox name="per_admin" value="1" |; ($auth_default_perm[4] and $perm .= "CHECKED"); $perm .= qq|>|;
}

to

Code:
# Build the permissions list if we haven't inquired in someone.
if (!$perm) {
$perm = qq|
View <input type=checkbox name="per_view" value="1" |; ($auth_default_perm[0] and $perm .= "CHECKED"); $perm .= qq|>
Add <input type=checkbox name="per_add" value="1" |; ($auth_default_perm[1] and $perm .= "CHECKED"); $perm .= qq|>
Delete <input type=checkbox name="per_del" value="1" |; ($auth_default_perm[2] and $perm .= "CHECKED"); $perm .= qq|>
Modify <input type=checkbox name="per_mod" value="1" |; ($auth_default_perm[3] and $perm .= "CHECKED"); $perm .= qq|>
Member <input type=checkbox name="per_mem" value="1" |; ($auth_default_perm[4] and $perm .= "CHECKED"); $perm .= qq|>
Admin <input type=checkbox name="per_admin" value="1" |; ($auth_default_perm[5] and $perm .= "CHECKED"); $perm .= qq|>|;
}

Now login as admin and change the permission for the user you added in the previous step. Change him to a non-member. Then exit and logon as the user and check the permission. Then logon as admin again and change the user back to a member. Once more log on as the new user and check the permission.

One other thing. Do take note of the other permissions to make sure nothing has changed with them. There shouldn't be a problem, but one never knows. Smile

This is just about done. If all this works, the only thing we'll need to do is set up your current .pass file (no small task! Smile ) and then you can use the permission as you want to.

I do want to thank you for your patience in this, Don. It's a lot easier to work things through one step at a time. Even if there's not a problem with any step, it really helps me to go in little bits rather than trying to see the whole thing at once.



------------------
JPD








[This message has been edited by JPDeni (edited April 09, 2000).]

[This message has been edited by JPDeni (edited April 09, 2000).]
Quote Reply
Re: Need Help with This...... In reply to
Oops. I forgot something. The lookup part. There are a number of things to change here. If you feel lucky, go ahead and make all the changes at once. If you are cautious like me, change the code in one subroutine and test it before you change the code in the next subroutine.

In db.cgi, sub lookup, change

Code:
my ($message, $userid, $pw, $view, $add, $del, $mod, $admin, $email, $password, $found, $output);

to

Code:
my ($message, $userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email, $password, $found, $output);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $found);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $found);

and change

Code:
print PASSWD "$userid:$encrypted:$view:$add:$del:$mod:$admin:$email\n";

to

Code:
print PASSWD "$userid:$encrypted:$view:$add:$del:$mod:$mem:$admin:$email\n";

---------------
If you're using sub get_email, you'll need to make some changes there, too.

Change

Code:
my ($userid, $pw, $view, $add, $del, $mod, $admin, $email);

to

Code:
my ($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $pass);

---------------
If you're using sub change email, make the following adjustments:

Change

Code:
my ($message, $userid, $pw, $view, $add, $del, $mod, $admin, $email, $password, $found, $output, $pass);

to

Code:
my ($message, $userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email, $password, $found, $output, $pass);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $pass);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $found);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $found);

and change

Code:
print PASS "$userid:$encrypted:$view:$add:$del:$mod:$admin:$in{'email'}\n";

to

Code:
print PASS "$userid:$encrypted:$view:$add:$del:$mod:$mem:$admin:$in{'email'}\n";

---------------
If you're using sub change_password, make the following adjustments:

Change

Code:
my ($message, $userid, $pw, $view, $add, $del, $mod, $admin, $email, $password, $found, $output);

to

Code:
my ($message, $userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email, $password, $found, $output);

and change

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $found);

to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $found);

and change

Code:
print PASS "$userid:$encrypted:$view:$add:$del:$mod:$admin:$email\n";

to

Code:
print PASS "$userid:$encrypted:$view:$add:$del:$mod:$mem:$admin:$email\n";



------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
OK - we are now encountering our first problem. After making all of the above changes. We have lost admin permissions.

When clicking on the "admin" link - I receive "Unauthorized Action".

Also - I noticed in the changes you have this line:
Code:
print PASS "$in{'new_username'}:$encrypted:$in{'per_view'}:$in{'per_add'}:$in{'per_del'}:$in{'per_mod'}:$in{'per_mod'}:$in{'per_admin'}:$in{'email'}\n" ;
Shouldn't one of the $in{'per_mod'} be $in{'per_mem'} ?

Oooops you posted before I had a chance to respond LOL. I mean the changes before your last post here.
---------------
donm


[This message has been edited by donm (edited April 09, 2000).]
Quote Reply
Re: Need Help with This...... In reply to
Yep. You caught the error I made before. You are absolutely right. I'll go back and make that change after I finish answering this. (See what happens when I go too fast? Smile )

I'll go back over sub admin_display and see if I can find somewhere else that I need to change.





------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
Check the .pass file and see if the 1 for "admin" is gone from the permission. That will help tell me if there is a problem with reading the file or with writing to it.


------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
No - the "1" for admin is still there.
Quote Reply
Re: Need Help with This...... In reply to
I did see one possibility. There are two instances of the line:

Code:
($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass);

that you need to change to

Code:
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email) = split (/:/, $pass);

I'm not sure if that would cause the problem or not. That's the only thing I can see. Give that a try and let me know what happens.


------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
OK - I found 5 instances of that line in db.cgi and changed them all still no luck with "admin" - I still receive "Unauthorized Action" when clicking on the admin link.

-----------------
donm
Quote Reply
Re: Need Help with This...... In reply to
Can you post your .pass file so I can get a look at it? (I don't think there will be a problem with security, since the passwords are encrypted. And you can always delete it after we're finished.)


------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
Sure I can - it's a test database anyway....(didn't wanna try this on my "live" database's yet) nothing in there as of yet except dummy accounts.
Code:
# UserID : Password : View : Add : Del : Mod: Member: Admin:Email
donm77:Q.EulTRri8ul6:1:1:1:1:1:1:donm@erinet.com
admin:Q.EulTRri8ul6:1:1:1:1:1:1:donm@erinet.com
author:Q.EulTRri8ul6:1:1:1:1:1:0:donm@erinet.com
guest:Q.EulTRri8ul6:0:1:0:1:0:0:donm@erinet.com
test1:JgYi7E4aQJtu2:0:1:0:1:1:0:blaznfyre@hotmail.com

BTW - thank you for your patience with my lack of Perl knowledge... I am learning alot though. This is one thing though that I was not ready to try and tackle alone.

-----------------------
donm
Quote Reply
Re: Need Help with This...... In reply to
You're welcome. This is obviously a tough nut to crack anyway.

Your password file looks okay.

Try this. Add some more debugging lines to sub html_home.

Code:
print "View -- $per_view<BR>
Add -- $per_add<BR>
Modify -- $per_mod<BR>
Delete -- $per_del<BR>
Member -- $per_mem<BR>
Admin -- $per_admin";

Login with all the usernames and see what you get. (I probably should have had you do that in the first place so we could keep an eye on things.)



------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
ok after adding the above code to sub html_home - this is what we have:

donm77 - view-1, add-1, modify-1, delete-1, member-1, admin-1
Admin - view-1, add-1, modify-1, delete-1, member-1, admin-1
Author - view-1, add-1, modify-1, delete-1, member-1, admin-0
Guest - view-0, add-1, modify-1, delete-0, member-0, admin-0
test1 - view-0, add-1, modify-1, delete-0, member-1, admin-0

----------------------
donm
Quote Reply
Re: Need Help with This...... In reply to
I don't understand. If you have $per_admin for your user, why wouldn't it-- wait a minute.

I know. Smile

In auth.pl, sub auth_check_permissions, change

Code:
my ($username, @permissions, $permission, $name, $pw, $view, $add, $del, $mod, $admin);

to

Code:
my ($username, @permissions, $permission, $name, $pw, $view, $add, $del, $mod, $mem, $admin);

and change

Code:
($name, $pw, $view, $add, $del, $mod, $admin) = split (/:/, $permission);
if ($username eq $name) {
$view = int($view); $add = int($add); # We int everything just in case
$del = int($del); $mod = int($mod); # someone has put spaces after the permssions.
$admin = int($admin);
return ($view, $add, $del, $mod, $admin);
}

to

Code:
($name, $pw, $view, $add, $del, $mod, $mem, $admin) = split (/:/, $permission);
if ($username eq $name) {
$view = int($view); $add = int($add); # We int everything just in case
$del = int($del); $mod = int($mod); # someone has put spaces after the permssions.
$admin = int($admin); $mem = int($mem);
return ($view, $add, $del, $mod, $mem, $admin);
}

That oughta do it. (Minor detail. I had taken care of the permission when the user logged in, but not when they actually tried to do something. Smile )



------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
OK - admin is now working. However, when I tried to change the permissions on the test1 account through the Admin Panel - this is what happened:
Code:
# UserID : Password : View : Add : Del : Mod: Member: Admin:Email
donm77:Q.EulTRri8ul6:1:1:1:1:1:1:donm@erinet.com
admin:Q.EulTRri8ul6:1:1:1:1:1:1:donm@erinet.com
author:Q.EulTRri8ul6:1:1:1:1:1:0:donm@erinet.com
guest:Q.EulTRri8ul6:0:1:0:1:0:0:donm@erinet.com
:::1::1:::
As you can see it corrupted the test1 account.

BTW - before changing test1 - I noticed in the admin panel that test1's email address was also missing and was replaced by a "0".

-----------------------
donm
Quote Reply
Re: Need Help with This...... In reply to
Oops! That isn't good.

Let me look over it again and see what I can come up with. I'll post as soon as I come up with something.


------------------
JPD






Quote Reply
Re: Need Help with This...... In reply to
For some reason in the admin panel - it is pulling some sort of permission in the form of a "1" or "0" depending who you are logged in as and placing it in the email field.

----------------------
donm
> >