Skip to content

Commit

Permalink
Fix user account setup tool
Browse files Browse the repository at this point in the history
closes #22
  • Loading branch information
abh committed Apr 29, 2012
1 parent b389e92 commit 4bcf19f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
27 changes: 0 additions & 27 deletions bin/pdnsapi_manage

This file was deleted.

28 changes: 28 additions & 0 deletions lib/Mojolicious/Command/account.pm
@@ -0,0 +1,28 @@
package Mojolicious::Command::account;
use Mojo::Base 'Mojo::Command';

has description => "Setup a new user account/password.\n";
has usage => "usage: $0 account [username] [password]\n";

sub run {
my ($self, $user, $password) = @_;

die $self->usage unless $user && $password;

my $schema = $self->app->schema;

my $account = $schema->account->find({ name => $user });

if ($account) {
$account->password($password);
$account->update;
print "Account updated\n";
}
else {
$schema->account->create({ name => $user, password => $password });
print "Account created\n";
}

}

1;
3 changes: 1 addition & 2 deletions lib/PowerDNS/API.pm
@@ -1,6 +1,5 @@
package PowerDNS::API;
use Mojo::Base 'Mojolicious';
#use PowerDNS::API::Handler::API;
use PowerDNS::API::Schema;
use Data::Dump ();

Expand Down Expand Up @@ -85,7 +84,7 @@ L<http://github.com/devel/PowerDNS-API>
=head1 COPYRIGHT & LICENSE
Copyright 2011 Ask Bjørn Hansen, all rights reserved.
Copyright 2011-2012 Ask Bjørn Hansen, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Expand Down
File renamed without changes.

0 comments on commit 4bcf19f

Please sign in to comment.