Skip to content

Commit

Permalink
fix OpenID auth. Required column renaming to match new authinfo from …
Browse files Browse the repository at this point in the history
…OpenID credential. added display => display_name method alias as a temporary fix as well.
  • Loading branch information
bricas committed Jul 21, 2009
1 parent 9279bb8 commit c1d14a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 55 deletions.
55 changes: 4 additions & 51 deletions lib/CPANHQ/Controller/Authenticate.pm
Expand Up @@ -28,60 +28,13 @@ Login using OpenID.
sub login : Path('/login') Args(0) {
my ( $self, $c ) = @_;
my $form = $c->form( 'Login' );
$form->action($c->uri_for('/authenticate/openid'));
$c->stash( form => $form, title => 'Login' );

return;

=begin Hello
return unless $form->was_submitted && $form->is_valid;
my $consumer = Net::OpenID::Consumer->new(
ua => LWPx::ParanoidAgent->new,
args => $c->req->params,
consumer_secret => sub { $_[0] },
);
my $identity = $consumer->claimed_identity( $form->field_value( 'claimed_uri' ) );
my $url = $identity->check_url(
return_to => $c->uri_for('/authenticate/openid'),
trust_root => $c->uri_for('/'),
delayed_return => 1,
);
$c->res->redirect( $url );
=end Hello
=cut

}

=head2 $self->openid($c)
Login using OpenID.
=cut

sub openid : Path('openid') Args(0) {
my( $self, $c ) = @_;

if ($c->authenticate({}, "openid"))
{
$c->persist_user();
$c->flash(message => "You signed in with OpenID!");
if( $c->authenticate ) {
$c->res->redirect( $c->uri_for('/') );
return;
}
else
{
$c->flash(message => "Could not authenticate with OpenID");
$c->response->body( "Could not authenticate with OpenID" );
# $c->flash(message => "Could not authenticate with OpenID");
# $c->response->body( "Could not authenticate with OpenID" );
# Catalyst::Exception->throw(
# 'Error validating identity: '
# );
}
return;

$c->stash( form => $form, title => 'Login' );
}

=head2 $self->logout($c)
Expand Down
3 changes: 2 additions & 1 deletion lib/CPANHQ/ResultSet/Account.pm
Expand Up @@ -7,7 +7,8 @@ use base qw( DBIx::Class::ResultSet );

sub auto_create {
my ( $self, $authinfo ) = @_;
$self->create( { openid => $authinfo->{ openid }, } );
# TODO: handle results from OpenID ext.
$self->create( { url => $authinfo->{ url }, } );
}

1;
Expand Down
7 changes: 4 additions & 3 deletions lib/CPANHQ/Storage/Account.pm
Expand Up @@ -33,7 +33,7 @@ __PACKAGE__->add_columns(
is_auto_increment => 1,
is_nullable => 0,
},
openid => {
url => {
data_type => 'varchar',
size => 512,
is_nullable => 0,
Expand All @@ -57,7 +57,7 @@ __PACKAGE__->add_columns(
);
__PACKAGE__->set_primary_key( 'id' );

__PACKAGE__->add_unique_constraint( [ 'openid' ] );
__PACKAGE__->add_unique_constraint( [ 'url' ] );

=head2 $self->display_name()
Expand All @@ -67,9 +67,10 @@ Returns a display name for the account.

sub display_name {
my $self = shift;
return $self->username || $self->openid;
return $self->username || $self->url;
}

*display = \&display_name;

=head1 SEE ALSO
Expand Down

0 comments on commit c1d14a6

Please sign in to comment.