Gossamer Forum
Home : Products : DBMan : Customization :

Auto Password Delete?

Quote Reply
Auto Password Delete?
Hi Carol..I searched the archives looking for but couldn't find any code that would or could automaticly delete a User ID & Password when a User Deleted a record..is this available to your knowledge?....Rob
Quote Reply
Re: Auto Password Delete? In reply to
There isn't a mod that does exactly what you're asking, although something similar has been added recently to the "autodelete" mod.

This one shouldn't be too hard.

In db.cgi, sub delete_records, change

Code:
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.
}

to

Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
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) {
($passline =~ /^$data[$auth_user_field]:/) ?
($found = 1) :
print PASS $passline;
}
close PASS;
}
else {
$output .= $line . "\n";
}

I have only checked this for syntax errors, not for functionality, so be sure you back up all of your data before you try it.


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





Quote Reply
Re: Auto Password Delete? In reply to
Hi Carol...transferred code as directed (serveral times)...but keep getting "Server Errors" ....thanks Rob
Quote Reply
Re: Auto Password Delete? In reply to
Can you post your db.cgi file so I can see where the error is? (You know, copy it to a web-accessible directory -- yadda, yadda, yadda.)



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





Quote Reply
Re: Auto Password Delete? In reply to
Hi Carol....here's a path displaying the db.txt..have a little look...thanks Rob
http://www.canadacentre.com/test/db.txt
Quote Reply
Re: Auto Password Delete? In reply to
My fault. I wasn't careful in the code I copied for you to delete.

Add another } after

Code:
else {
$output .= $line . "\n";
}

so it looks like

Code:
else {
$output .= $line . "\n";
}
}

That will get rid of your 500 error.


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





Quote Reply
Re: Auto Password Delete? In reply to
Hi Carol that was the problem..script works fine...but..here comes the BIG but...please be tolerant, I'm feeling kind of quilty asking for a tad more...can we get this script to check the database to see if the user has any other records under his Username before it deletes the password..if he others it doesn't delete..if he has none then it deletes...what do you think? enternally greatful...Rob
Quote Reply
Re: Auto Password Delete? In reply to
I was thinking of suggesting that you only use this mod if you only allow users to have one record each.

The trouble is that, until the subroutine is finished, the original record still exists in the database. Possibly I could give you code that would check if the user only deleted one record at a time, but I'm not even sure about that. Allowing for multiple deletes would, I'm sure, be theoretically possible, but it makes my brain sore to think about it.


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





Quote Reply
Re: Auto Password Delete? In reply to
Hi again...I can and will use the present script for one record database enteries...but multiple sounds like quite a feat...thanks for the current script...Rob
Quote Reply
Re: Auto Password Delete? In reply to
Anyone know how to get this to work with the Validate mod so that if you chose to delete a record instead of validating it, it will also delete the userid/pass?

[This message has been edited by xev (edited March 05, 2000).]
Quote Reply
Re: Auto Password Delete? In reply to
Xev:

I don't know exactly how to do this but I think the following thread may help you.

http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/001153.html

Author
Topic: Deleting user records in relational database

Alhough it's for the relational mod it may provide the information on how this could be done.

Hope it helps Smile
Quote Reply
Re: Auto Password Delete? In reply to
Since you are considering deleting a record along with the userid/pass,
I assume you are dealing with a user profile DB and effectively "rejecting"
a user, yes? If so, here's something to think about: When you delete
a record, do you want to prevent someone from just resubmitting (and
making you validate/delete again)? If so, I probably wouldn't delete the
userid/password, but either change a status field to "Inactive" as opposed
to "Member" (elegant solution) or change the password (brute force) so that
they can't immediately re-subscribe.


------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)



[This message has been edited by oldmoney (edited March 05, 2000).]
Quote Reply
Re: Auto Password Delete? In reply to
 
Quote:
or change the password (brute force) so that they can't immediately re-subscribe.
A little simpler method in the same vein might be to just change their user permissions through the admin screen. Let them view, but not add, modify, or delete.

Dan