Commit 6d9a7855 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#45] New field is temporary for users

parent ec4ff75d
......@@ -74,7 +74,9 @@ sub add_user {
$is_admin = 1 if $is_admin_q =~ /y/i;
Ravada::Auth::SQL::add_user($login, $password, $is_admin);
Ravada::Auth::SQL::add_user( name => $login
, password => $password
, is_admin => $is_admin);
}
sub add_user_ldap {
......
......@@ -291,7 +291,7 @@ sub _check_user_profile {
my $user_sql = Ravada::Auth::SQL->new(name => $self->name);
return if $user_sql->id;
Ravada::Auth::SQL::add_user($self->name , undef, 0);
Ravada::Auth::SQL::add_user(name => $self->name);
}
sub _match_password {
......
......@@ -61,13 +61,30 @@ sub search_by_id {
Adds a new user in the SQL database. Returns nothing.
Ravada::Auth::SQL::add_user($user, $pass, $is_admin);
Ravada::Auth::SQL::add_user(
name => $user
, password => $pass
, is_admin => 0
, is_temporary => 0
);
=cut
sub add_user {
my %args = @_;
_init_connector();
my ($login,$password, $is_admin ) = @_;
my $name= $args{name};
my $password = $args{password};
my $is_admin = ($args{is_admin} or 0);
my $is_temporary= ($args{is_temporary} or 0);
delete @args{'name','password','is_admin','is_temporary'};
confess "WARNING: Unknown arguments ".Dumper(\%args)
if keys %args;
my $sth = $$CON->dbh->prepare(
"INSERT INTO users (name,password,is_admin) VALUES(?,?,?)");
......@@ -76,7 +93,7 @@ sub add_user {
} else {
$password = '*LK* no pss';
}
$sth->execute($login,$password,$is_admin);
$sth->execute($name,$password,$is_admin);
$sth->finish;
}
......
angular.module("ravada.app",['ngResource'])
angular.module("ravada.app",['ngResource','ngSanitize'])
.directive("solShowSupportform", swSupForm)
.directive("solShowNewmachine", swNewMach)
.directive("solShowListmachines", swListMach)
......
......@@ -985,7 +985,7 @@ sub _new_anonymous_user {
last if !$user;
}
warn "\n*** creating temporary user $name";
Ravada::Auth::SQL::add_user($name);
Ravada::Auth::SQL::add_user(name => $name, is_temporary => 1);
return $name;
}
......
......@@ -4,6 +4,7 @@ CREATE TABLE `users` (
`password` char(255) DEFAULT NULL,
`change_password` char(1) DEFAULT 'N',
`is_admin` char(1) DEFAULT 'N',
`is_temporary` char(1) DEFAULT 'N',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
);
......
......@@ -4,6 +4,7 @@ CREATE TABLE `users` (
`password` char(255) DEFAULT NULL,
`change_password` char(1) DEFAULT 'N',
`is_admin` char(1) DEFAULT 'N',
`is_temporary` char(1) DEFAULT 'N',
UNIQUE (`name`)
);
......@@ -13,7 +13,7 @@ use_ok('Ravada::Auth::SQL');
my $RAVADA = Ravada->new(connector => $test->connector);
Ravada::Auth::SQL::add_user('test',$$);
Ravada::Auth::SQL::add_user(name => 'test',password => $$);
ok($$Ravada::Auth::SQL::CON,"Undefined DB connection");
......
......@@ -12,7 +12,7 @@ my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
my $ravada = Ravada->new(connector => $test->connector);
Ravada::Auth::SQL::add_user('root','root', 1);
Ravada::Auth::SQL::add_user(name => 'root', password => 'root', is_admin => 1);
Ravada::Auth::LDAP(0);
......@@ -43,7 +43,7 @@ Ravada::Auth::LDAP(0);
}
Ravada::Auth::SQL::add_user('mcnulty','jameson');
Ravada::Auth::SQL::add_user(name => 'mcnulty', password => 'jameson');
{
my $mcnulty= Ravada::Auth::SQL->new(name => 'mcnulty',password => 'jameson');
......
......@@ -151,7 +151,7 @@ sub remove_old_disks {
sub create_user {
my ($name, $pass, $is_admin) = @_;
Ravada::Auth::SQL::add_user($name, $pass, $is_admin);
Ravada::Auth::SQL::add_user(name => $name, password => $pass, is_admin => $is_admin);
my $user;
eval {
......
......@@ -24,7 +24,7 @@ sub test_create_user {
my $name = shift;
my $is_admin = shift or 0;
Ravada::Auth::SQL::add_user($name, 'bar', $is_admin);
Ravada::Auth::SQL::add_user(name => $name, password => 'bar', is_admin => $is_admin);
my $user = Ravada::Auth::SQL->new(name => $name, password => 'bar');
if ($is_admin) {
......
Supports Markdown
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