<commit_before>package CoGe::Accessory::LogUser;

use strict;
use CGI::Cookie;

sub get_user
  {
    my %cookies = fetch CGI::Cookie;
    my $email = "not logged in";
    if (ref $cookies{"Session"})
      {
	my %session = $cookies{"Session"}->value;
	$email = $session{email} if $session{"email"};
      } 
    else
      {
	$email = $ENV{'REMOTE_USER'} if $ENV{'REMOTE_USER'};
      }
    return $email;
  }

1;<commit_msg>added support for locally generated cookies for user login<commit_after>package CoGe::Accessory::LogUser;

use strict;
use CGI::Cookie;
use Data::Dumper;

use vars qw($cookie_name);

$cookie_name = "CoGe";

sub get_user
  {
    my $self = shift;
    my %cookies = fetch CGI::Cookie;
    my ($user, $uid, $session);# = "Public";
    if (ref $cookies{$cookie_name})
      {
	my %session = $cookies{$cookie_name}->value;
	$user = $session{user_name} if $session{user_name};
	$uid = $session{uid} if $session{uid};
	$session = $session{session} if $session{session};
      }
    return ($user, $uid, $session);
  }

sub gen_cookie
  {
    my $self = shift;
    my %opts = @_;
    my $user_name = $opts{user_name};
    my $uid = $opts{uid};
    my $expires = $opts{exp} || "+24h";
    my $session = $opts{session};
    $expires = "+".$expires unless $expires =~ /^\+/;
    
    my $c = new CGI::Cookie(-name=>$cookie_name,
			    -expires=>$expires,
			    -values=>{
				      user_name=>$user_name,
				      uid => $uid,
				      session=>$session,
				     },
			    );
    return $c;
  }



1;
{'fraction_non_alphanumeric': 0.17314022383146807, 'fraction_numerical': 0.0026333113890717576, 'mean_word_length': 2.948051948051948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2643375', 'n_tokens_mistral': 591, 'n_tokens_neox': 553, 'n_words': 128}