Catalyst Maintainable web apps made easy! #122

Actions for API key management

sub get_api_key :Local {
    my ($self, $c) = @_;
    $c->detach('/not_found') unless $c->user;

    my $key = $c->user->get_api_key;
    $c->stash->{key} = $key->apikey;
    $c->view->template('account/api_key');
}

sub invalidate_api_keys :Local {
    my ($self, $c) = @_;
    $c->detach('/not_found') unless $c->user;
    $c->user->api_keys->delete; # DBIC::Restricted::ApiKeys->delete also ok

    $c->view->template('account/cleared_keys');
}
Copyright © 2007 Jonathan Rockway