Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Utils.pm
- ####################
- sub AuthenticateUser
- {
- my $user = shift;
- my $passwd = shift;
- my $privs = shift;
- my $res;
- my $authlink = $Globals::baseurl."/cgi-bin/auth.pl";
- # now we have to authenticate the user
- $res = CGI_ats::GetUserandPasswd(\$user, \$passwd, \$privs);
- #$res = 1;
- if (!$res)
- {
- print "<meta http-equiv=\"REFRESH\"content=\"0;url=$authlink?caller=".$CGI_at$
- Utils::HTMLFailure("Failed to get cookie info", 1);
- }
- return($res);
- }
- ################
- # CGIats.pm
- sub GetUserandPasswd
- {
- my ($user, $password, $privs) = @_;
- my $cookie = $CGI_ats::query->cookie($CGI_ats::ats_cookie_name);
- #Check it was defined
- if(! defined $cookie)
- {
- Utils::HTMLFailure("Failed to get $CGI_ats::ats_cookie_name cookie");
- return 0;
- }
- my @cookie_content = split(/\,/, MIME::Base64::decode($cookie));
- # check if had valid content
- if(! scalar @cookie_content)
- {
- Utils::HTMLFailure("Failed to get $CGI_ats::ats_cookie_name cookie");
- return 0;
- }
- $$user = $cookie_content[0];
- $$password = MIME::Base64::decode($cookie_content[1]);
- $$privs = $cookie_content[2];
- return 1;
- }
- ##############
- # auth.pl
- if(defined $CGI_ats::query->param('op'))
- {
- if($CGI_ats::query->param('op') eq 'login')
- {
- # make sure we have a name and password before we
- # enter the poll loop
- if(! defined $CGI_ats::query->param('name') ||
- ! $CGI_ats::query->param('name') ||
- ! defined $CGI_ats::query->param('passwd') ||
- ! $CGI_ats::query->param('passwd'))
- {
- $error_text = "<p>User name and password not supplied</p>\n";
- }
- else
- {
- # we have to enter a poll loop to do this
- enter_poll();
- }
- ###############
- # results.pl
- $res = Utils::AuthenticateUser(\$user, \$passwd, \$privs);
- if (!$res)
- {
- exit(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement