# HG changeset patch # User sergey # Date 1356736935 -14400 # Node ID 4ac39b9e2ca48431ff2e1a13b65fb137e5327bbb # Parent 93963ec449c5de235b9863780280a1efe99f6438 sync diff -r 93963ec449c5 -r 4ac39b9e2ca4 Lib/IMPL/Web/Handler/SecureCookie.pm --- a/Lib/IMPL/Web/Handler/SecureCookie.pm Fri Dec 28 16:43:03 2012 +0400 +++ b/Lib/IMPL/Web/Handler/SecureCookie.pm Sat Dec 29 03:22:15 2012 +0400 @@ -32,6 +32,14 @@ $this->salt('DeadBeef') unless $this->salt; } +sub ValidateCookie { + my ($this,$sid,$cookie,$sign) = @_; + + return 1 if $sid and $cookie and $sign and $sign eq md5_hex($this->salt,$sid,$cookie,$this->salt); + + return 0; +} + sub Invoke { my ($this,$action,$nextHandler) = @_; @@ -45,17 +53,7 @@ my $cookie = $action->cookie('sdata',qr/(\w+)/); my $sign = $action->cookie('sign',qw/(\w+)/); - if ( - $sid and - $cookie and - $sign and - $sign eq md5_hex( - $this->salt, - $sid, - $cookie, - $this->salt - ) - ) { + if ( $this->ValidateCookie($sid,$cookie,$sign) ) { # TODO: add a DefferedProxy to deffer a request to a data source if ( $context = $this->_manager->GetSession($sid) ) { if ( eval { $context->auth->isa(AuthSimple) } ) {