Gossamer Forum
Home : Products : DBMan : Customization :

Password/Permissions problem

Quote Reply
Password/Permissions problem
Hi there!!

Some Background information
I have set my database up with the user permissions of Add, Delete, View. After I have Validated the record (that is accepted the new user as a member of the database or rejected the new user) I then access User Mangaement and assign the Accepted User with the modify function as well.

The reason I have done this is because I have given my users the ability to signup on line and some users also provide information that they may or maynot want to be public. I have set this up via public/private check box (see code below) to reveal the information to full members, while hiding it from members not yet validated and default users.
Code:
if ($rec{'Public'}) {
print qq||;
if ($per_mod) {
print qq|
<TR><TD COLSPAN="2" ALIGN="Right" VALIGN="Top"><$font_color>About Me:</FONT></TD>
<TD COLSPAN="3"><$font> $rec{'About Me'}</Font></TD></TR>
|;
}
print qq|
|;
}
Ok my problem is that when I change a persons permissions via the admin screen. I am changing the password as well.

What I have found is that unless I actually type in the persons password at the same time as I set the 4 Permissions I am changing the users password to blank.

What this means is that when the user tries to sign on using
Username/originally chosen password they get access denied etc.
But if they sign on using
Username/leaving the password field blank they can access the database no problem.

Any ideas as to why I need to reenter the the persons password when I modify thier permissions?

Anyway that is the first little hiccup, the next thing is that I had been going to ask how I could get dbman to amend the user permissions (to include modify) automatically once the record has been validated.

I have found this code while searching through the forum and it sounds like it might be close to what I am wanting.
Code:
What I have done is to force a new user to add if he does not currently have a record in the database.

Set your $db_key field to be the userid field. (Since you just want one record per user, this is the way to go anyway.)

In sub html_home, add


code:
--------------------------------------------------------------------------------

%rec = &get_record($db_userid);
unless ($rec{$db_key}) {
$in{'add_form'} = 1;
&html_add_form;
return;
}

--------------------------------------------------------------------------------

This will cause the script to search for a record for the user as soon as he logs in. If a record is not found, he will be sent to the add form.

Give permissions of (1,1,1,1,0) to those signing up, but

1-- Take the "Add" link out of sub html_footer

and

2-- Take the footer out of sub html_add_form.
which is.

A new user will have access to view and add record only. Once the record is validated then the above code would allow the user to have access to the delete and modify also.

I realise the above code as it is written currently doesn do this, and I'm hoping that someone will be able to modify for the code so it will.

Many thanks
Seer

Oh yes by the way my users can only add one record per user.

Quote Reply
Re: Password/Permissions problem In reply to
What modifications have you added to DBMan? You shouldn't be having the problem with the password.

When you do the "Inquire" for the person, doesn't the password show up in the password field?

Are you using the "Validate Records" mod? It seems so from your post, but I've learned not to assume anything. Smile

Still, I'll go ahead and give you the code for changing the permission that would go with the mod. If you need something else, let me know.

In sub validate_records, after

$output .= &join_encode(%rec);

add

Code:

open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1); }
@passlines = <PASS>;
close PASS;

open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
my $found = 0;
foreach $passline (@passlines) {
if ($passline =~ /^$rec{$db_cols[$auth_user_field]}:/) {
my $password = (split (/:/, $line))[1];
print PASS $rec{$db_cols[$auth_user_field]}:$password:1:1:1:1:0\n";
}
else {
print PASS $passline;
}
}
close PASS;
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
JP

Oh Boy where to start!! This second database has been a real learning exercise. Biggest one is to keep a record of what changes I make and when. I usually just make backups of the files with pre and post names of what I did. Still a little confusing, but I'm pretty sure this is correct the order of the changes

Date last modified
Short_Changes2
Column record display
public/private check box
Validate record

I did do the modification that when your user logs in they are sent straight to the view all page. I deleted those modifications because for some reason when I clicked on the short modification link to take me to the long record it would return me to the Logon screen.

When I do and "Inquire" the encrypted password shows .... when I modified the User record all I did was use the drop down menu to select thier name from and then I checked the 4 permission boxes ... I guess this is perhaps where I have caused the problem?? Should I have clicked on "Inquire" first and then clicked the permissions to be updated.

As to the coding you have posted I haven't had a look at it yet, let alone implimented it. I would like to fix one problwm before compounding it any further.


Thanks Seer

Quote Reply
Re: Password/Permissions problem In reply to
In Reply To:
Should I have clicked on "Inquire" first and then clicked the permissions to be updated.
Yep. That will solve your problem with the password being lost. The problem is that, unless you have done an "Inquire" first, the script thinks you're entering a new user instead of updating one.

However, the code I gave you should make the changes for you, so you won't have to worry about it.

In Reply To:
I did do the modification that when your user logs in they are sent straight to the view all page. I deleted those modifications because for some reason when I clicked on the short modification link to take me to the long record it would return me to the Logon screen.
I don't remember the modification. What was the code? Maybe I can figure out the problem.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
In Reply To:
Yep. That will solve your problem with the password being lost.
JP Thank you I am so pleased it is User error and not coding error. Smile As to

In Reply To:
I don't remember the modification. What was the code? Maybe I can figure out the problem.
Um I picked this piece of code up of Lois's site "Awesome site there Lois ... been living there the last couple of weeks"

Code:
Automatically list all records when a users logs on

Does anybody know of a way to automatically list all records when a users logs on?

Response:

At the beginning of sub html_home, you could add:

$in{$db_key} = "*";
&view_records;
return;
This is what I did and where I put it ...

I'll now move on and insert the code you gave me.

Thank you for your help Smile
Seer


Quote Reply
Re: Password/Permissions problem In reply to
Ah, yes. I remember that now.

It's not going to work with the short/long display, though, because the links to the long display depend on the "query string" (the part of the URL that's after the ?) in order to work.

I'll bet this would work, though.

print "Location: $db_script_link_url&$db_key=*&view_records=1\n\n"

Give that a try and see if it works better.

I agree about Lois's site. She has managed to catalog uncountable things from the forum. I am forever in her debt!!


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
Thanks for the code JP I will try it Smile

In the mean time with the piece of code listed above I am haing trouble with Server 500 errors.

1. I assumed that the code was to go in the db.cgi file as it was the only place I could find sub validate_records and the piece of code $output .= &join_encode(%rec);

2. Yes I have uploaded in ascii and yes it is chmoded to 755.

When I take the piece of code out again it works fine.

You will find the code here if you would like to check it. http://sugilite.virtualave.net/members/db.txt

Many Thanks for your time

Seer

Quote Reply
Re: Password/Permissions problem In reply to
My fault. I left out a quotation mark.

print PASS "$rec{$db_cols[$auth_user_field]}:$password:1:1:1:1:0\n";

With the quotation mark in place, no more syntax error.

Sorry 'bout that.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
JP

Thank you so much for your time and effort. That quote does fix the error 500's.

I'm still having trouble with the password, so I am going to rebuild this from scratch again. Hopefully now that I know exactly what I want there wont be so much trial and error. I will get back to you when I have finished and let you know how I got on.

Again many thanks
Seer

Quote Reply
Re: Password/Permissions problem In reply to
Seer and JP:

Thanks for the input regarding the DBMan Unofficial FAQ. It's so nice to know that it is being used and helping others as intended, and that the months I've spent gathering the information is serving a purpose.

The FAQ is an excellent example of the endless help JPDeni has provided to DBMan users. And all the possibilities she has provided for creating great databases.

And we can't forget the others who have made some valuable contributions also Smile



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
JP

I have just finished redoing my database, and the problem that I had originally re the password is of course fixed with doing an inquiry.

I find now that I have a problem since installing the code listed above.

It seems that when the record is validated the password file is updated with all the fields of the record as the password.
In Reply To:
Tui://avatarsoa.virtualave.net/images/iconpv.jpg|Tui|1|2|3|royal_azel@hotmail.com|4|5|6||||||||No|10-Jul-2000|10-Jul-2000:1:1:1:1:0
You can view the files at
http://sugilite.virtualave.net/members/aam-cgi.txt

Look forward to hearing from you

Lois you are correct, your site, plus JP, plus everyones help makes this an awesome support forum. Smile

Thank you
Seer


Quote Reply
Re: Password/Permissions problem In reply to
I'm going to need to see your db.cgi file. Copy it to a web-accessible directory (one where you woule place .html files) and rename it to db_cgi.txt. Then come back here and tell me where I can find it. I'll take a look.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
Hi JP

I did as you asked in my previous post, but here is the link again .... note I have changed it from db.cgi to aam.cgi

http://sugilite.virtualave.net/members/aam-cgi.txt

Much appreciated
Seer

Quote Reply
Re: Password/Permissions problem In reply to
My apologies. I guess I stopped reading at the point where you described your problem.

I found it. My mistake

Code:

foreach $passline (@passlines) {
if ($passline =~ /^$rec{$db_cols[$auth_user_field]}:/) {
my $password = (split (/:/, $passline))[1];
print PASS "$rec{$db_cols[$auth_user_field]}:$password:1:1:1:1:0\n";
}
else {
print PASS $passline;
}
I thought I'd changed all the variables, but I missed one. Sorry 'bout that.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
Awesome Carol

It works wonderfully ... just a little more cosmetic titivation and it will be finished.

Many many thanks
Tui
aka Seer

Quote Reply
Re: Password/Permissions problem In reply to
Cool! I'd love to see it when it's done. Smile

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Password/Permissions problem In reply to
I'm sure I can manage that I will send you a link Smile

Seer