Gossamer Forum
Home : Products : DBMan : Customization :

Log Off After sub html_add_success

Quote Reply
Log Off After sub html_add_success
What code would I add to logoff the user right after they add a new record?

I want the sub html_add_success page to load first showing sub html_record_long first before closing out the authentication?

Would like the same line of code for modify and delete as well if anyone can help.

Thanks!
Quote Reply
Re: [BrianYork] Log Off After sub html_add_success In reply to
I can think of 2 ways off the top of my head;

1. A html meta tag refresh with the URL of the meta tag causing the log-off. (you know the kind that lets them look at the add_sucess page for 10 seconds then refreshes to the log-off).

2. Hum? I'm not so clear on idea number 2, but something like this; let add_sucess create a temp html file that is saved to the server (for the record), then it logs them off, then there is a setting for URL to go to following log-off. (which would be the temp html file), sounds complicated.

Not sure if there is anything like this in the FAQ, but always worth a try.
Quote Reply
Re: [joematt] Log Off After sub html_add_success In reply to
Joematt:

I added the folowing code in db.pl in sub add_record after &html_add_success and in sub modify_record after &html_modify_success;

Code:
opendir (AUTHDIR, "$auth_dir") || &cgierr("unable to open directory in auth_cleanup: $auth_dir. Reason: $!");
unlink ("$auth_dir/$db_uid");
closedir (AUTHDIR);


It works!

The user adds their record, is shown the sub html_add_success page or the sub html_modify success page and then the above code invokes and deletes the session id. If the user hits the back button on their web browser and tries to add another record again by hitting the submit button, the sub html_login_error page loads and they need to log in again.

This is a great little "hack" for those dbman users that only allow one record to be added at a time and want the user to be logged off right after adding the record. FYI...On the sub html_add_success page or the sub html_modify success page, if you are using this hack, do not print sub_html_footer (your navigation links for dbman) because if a user clicks on one of the links, they will have to log in again.
Quote Reply
Re: [BrianYork] Log Off After sub html_add_success In reply to
Well that's much better than either of my suggestions! Blush

Thanks for posting the solution.

I think I learned something new. (which of course is the reason I read this forum and try to help)

Thanks.
Quote Reply
Re: [joematt] Log Off After sub html_add_success In reply to
Glad I taught someone something!

Now, on a similar note:

After a user adds a record, how can I open up the password file, find the users userid, then delete them so they can't log in again?

I tried add the following in sub add_record afer &html_add_success;.

Code:
my (@lines,$line);open (PASS, ">>$hvacupgrades_pw_file") or &cgierr ("unable to open: $hvacupgrades_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 2) or &cgierr("unable to get exclusive lock on $hvacupgrades_pw_file.\nReason: $!"); }
@lines = <PASS>;
close PASS;
open (PASS, ">>$hvacupgrades_pw_file") or &cgierr ("unable to open: $hvacupgrades_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 2) or &cgierr("unable to get exclusive lock on $hvacupgrades_pw_file.\nReason: $!"); }
my $found = 0;
foreach $line (@lines) {
($line =~ /^$db_userid:/) ?
($found = 1) :
print PASS $line;
}
close PASS;


However, it does not work.

Any suggestions?
Quote Reply
Re: [BrianYork] Log Off After sub html_add_success In reply to
Well, all I could do was compare your code to the code in db.cgi that deletes a user from the password file.

I can see some differences, but couldn't tell you where you went wrong. If you hacked the code from the sub admin_display then you probably made the changes for a reason, but if not, I suggest you look at how they do it in the db.cgi script.

I thought there was a MOD that allowed a user to only have 1 record, but they can modify it, maybe that's not what you wanted.

Have a nice weekend!