Changeset 851 for trunk/DJabberd/lib/DJabberd/IQ.pm
- Timestamp:
- 02/11/09 21:57:06 (13 months ago)
- Files:
-
- 1 modified
-
trunk/DJabberd/lib/DJabberd/IQ.pm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DJabberd/lib/DJabberd/IQ.pm
r849 r851 496 496 my $digest = $get->("digest"); 497 497 498 return unless $username =~ /^\w+$/; 498 # "Both the username and the resource are REQUIRED for client 499 # authentication" Section 3.1 of XEP 0078 500 return unless $username && $username =~ /^\w+$/; 501 return unless $resource; 499 502 500 503 my $vhost = $conn->vhost; … … 518 521 519 522 # register 520 my $jid = DJabberd::JID->new("$authjid /$resource");523 my $jid = DJabberd::JID->new("$authjid"); 521 524 522 525 unless ($jid) { … … 527 530 my $regcb = DJabberd::Callback->new({ 528 531 registered => sub { 529 $conn->set_bound_jid($jid); 532 (undef, my $fulljid) = @_; 533 $conn->set_bound_jid($fulljid); 530 534 $DJabberd::Stats::counter{'auth_success'}++; 531 535 $iq->send_result; … … 540 544 }); 541 545 542 $vhost->register_jid($jid, $ conn, $regcb);546 $vhost->register_jid($jid, $resource, $conn, $regcb); 543 547 }; 544 548 … … 627 631 }; 628 632 629 my $resource = $get->("resource") 630 || Digest::SHA1::sha1_hex(rand() . rand() . rand()); 633 my $resource = $get->("resource") || DJabberd::JID->rand_resource; 631 634 632 635 my $vhost = $conn->vhost; … … 669 672 670 673 # register 671 my $jid = DJabberd::JID->new( "$authjid/$resource");674 my $jid = DJabberd::JID->new($authjid); 672 675 673 676 unless ($jid) { … … 678 681 my $regcb = DJabberd::Callback->new({ 679 682 registered => sub { 680 $conn->set_bound_jid($jid); 683 (undef, my $fulljid) = @_; 684 $conn->set_bound_jid($fulljid); 681 685 $DJabberd::Stats::counter{'auth_success'}++; 682 686 my $xml = <<EOX; 683 <iq id='$ id' type='result'>687 <iq id='$fulljid' type='result'> 684 688 <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> 685 <jid>$ jid</jid>689 <jid>$fulljid</jid> 686 690 </bind> 687 691 </iq> … … 699 703 }); 700 704 701 $vhost->register_jid($jid, $ conn, $regcb);705 $vhost->register_jid($jid, $resource, $conn, $regcb); 702 706 return 1; 703 707 }
