Commit e5964b57 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

add user in db from command line

parent d01453a3
......@@ -7,11 +7,18 @@ our $LDAP;
use Ravada::Auth::SQL;
eval { require Ravada::Auth::LDAP; $LDAP = 1 };
eval {
require Ravada::Auth::LDAP;
$LDAP = 1
};
sub init {
my ($config, $db_con) = @_;
Ravada::Auth::LDAP::init($config) if $LDAP;
if ($config->{ldap}) {
Ravada::Auth::LDAP::init($config);
} else {
$LDAP = 0;
}
Ravada::Auth::SQL::init($config, $db_con);
}
......
......@@ -17,7 +17,7 @@ sub add_user {
my $sth = $CON->dbh->prepare(
"INSERT INTO users (name,password) VALUES(?,?)");
$sth->execute(sha1_hex($password));
$sth->execute($login,sha1_hex($password));
$sth->finish;
}
......@@ -26,7 +26,7 @@ sub login {
my $sth = $CON->dbh->prepare(
"SELECT name FROM users WHERE name=? AND password=?");
$sth->execute(sha1_hex($password));
$sth->execute($login, sha1_hex($password));
my ($found) = $sth->fetchrow;
$sth->finish;
return if !$found;
......
......@@ -11,7 +11,7 @@ use lib 'lib';
use Ravada::Auth;
my $FILE_CONFIG = "/etc/ravada.conf";
my $FILE_CONFIG = "/etc/ravada_front.conf";
my $help;
GetOptions(
config => \$FILE_CONFIG
......@@ -39,6 +39,11 @@ any '/' => sub {
return quick_start($c);
};
any '/login' => sub {
my $c = shift;
$c->render(data => "TODO");
};
any '/logout' => sub {
my $c = shift;
$c->session(expires => 1);
......@@ -250,7 +255,7 @@ sub list_bases {
}
sub init {
Ravada::Auth::init($config);
Ravada::Auth::init($config,$CON);
}
app->start;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment