set the branch at login

This commit is contained in:
Joshua Ferraro 2007-08-07 15:45:03 -05:00
parent dbdb7f4feb
commit bf1fd83d08
3 changed files with 8 additions and 36 deletions

View file

@ -114,7 +114,6 @@ C4::Auth - Authenticates Koha users
sub get_template_and_user {
my $in = shift;
warn "GET Template";
my $template =
gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} );
my ( $user, $cookie, $sessionID, $flags ) = checkauth(
@ -217,7 +216,8 @@ sub get_template_and_user {
}
if ( $in->{'type'} eq "intranet" ) {
$template->param(
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
intranetuserjs => C4::Context->preference("intranetuserjs"),
@ -383,7 +383,7 @@ sub checkauth {
# state variables
my $loggedin = 0;
my %info;
my ( $userid, $cookie, $sessionID, $flags );
my ( $userid, $cookie, $sessionID, $flags, $envcookie );
my $logout = $query->param('logout.x');
if ( $userid = $ENV{'REMOTE_USER'} ) {
@ -545,14 +545,10 @@ sub checkauth {
# new op dev :
# launch a sequence to check if we have a ip for the branch, if we have one we replace the branchcode of the userenv by the branch bound in the ip.
my $ip = $ENV{'REMOTE_ADDR'};
# if they specify at login, use that
if ($query->param('branch')) {
$branchcode = $query->param('branch');
$branchname = GetBranchName($branchcode);
}
my $branches = GetBranches();
my @branchesloop;
foreach my $br ( keys %$branches ) {
# now we work with the treatment of ip
my $domain = $branches->{$br}->{'branchip'};
if ( $domain && $ip =~ /^$domain/ ) {
@ -591,17 +587,7 @@ sub checkauth {
$session->param('ip',$session->remote_addr());
$session->param('lasttime',time());
}
if ($session){
C4::Context::set_userenv(
$session->param('number'), $session->param('id'),
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter')
);
}
}
else {
if ($userid) {
$info{'invalid_username_or_password'} = 1;
@ -631,16 +617,8 @@ sub checkauth {
my $value = $query->param($name);
push @inputs, { name => $name, value => $value };
}
# get the branchloop, which we need for authetication
use C4::Branch;
my $branches = GetBranches();
my @branch_loop;
for my $branch_hash (keys %$branches) {
push @branch_loop, {branchcode => "$branch_hash", branchname => $branches->{$branch_hash}->{'branchname'}, };
}
my $template = gettemplate( $template_name, $type, $query );
$template->param(branchloop => \@branch_loop,);
$template->param(
INPUTS => \@inputs,
suggestion => C4::Context->preference("suggestion"),

View file

@ -91,7 +91,8 @@ foreach my $thisbranch (keys %$branches) {
=cut
sub GetBranches {
my ($onlymine)=@_;
my $onlymine=@_;
# returns a reference to a hash of references to ALL branches...
my %branches;
my $dbh = C4::Context->dbh;

View file

@ -43,17 +43,10 @@
<p>
<label>Password:<br />
<input type="password" name="password" id="password" class="input" value="" size="20" tabindex="20" /></label>
</p>
<p>
<label for="branch">Library:</label>
<select name="branch" id="branch" class="input">
<!-- TMPL_LOOP NAME="branchloop" -->
<option value="<!-- TMPL_VAR NAME='branchcode' -->"><!-- TMPL_VAR NAME='branchname' --></option>
<!-- /TMPL_LOOP -->
</select>
</p>
</p>
<p class="submit"><input type="submit" value="Login &raquo;" /></p>
</form>
<!-- /TMPL_IF -->
<script type="text/javascript">