Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
e46531cf
Commit
e46531cf
authored
Mar 08, 2021
by
Roberto P. Rubio
Browse files
Change Password (set default value)
parent
fbee56e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
e46531cf
...
...
@@ -1312,6 +1312,18 @@ sub _set_url_isos($self, $new_url='http://localhost/iso/') {
$sth
->
finish
;
}
sub
_get_column_info
{
my
$self
=
shift
;
my
(
$table
,
$field
)
=
@_
;
my
$dbh
=
$CONNECTOR
->
dbh
;
my
$sth
=
$dbh
->
column_info
(
undef
,
undef
,
$table
,
$field
);
my
$row
=
$sth
->
fetchrow_hashref
;
$sth
->
finish
;
return
$row
;
}
sub
_upgrade_table
{
my
$self
=
shift
;
my
(
$table
,
$field
,
$definition
)
=
@_
;
...
...
@@ -1655,6 +1667,18 @@ sub _clean_iso_mini {
$sth
->
finish
;
}
sub
_upgrade_users_table
{
my
$self
=
shift
;
my
$data
=
$self
->
_get_column_info
('
users
',
'
change_password
');
if
(
$data
->
{'
COLUMN_DEF
'}
==
1
)
{
my
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
UPDATE users set change_password=0
");
$sth
->
execute
;
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
ALTER TABLE users ALTER change_password SET DEFAULT 0
");
$sth
->
execute
;
}
}
sub
_upgrade_tables
{
my
$self
=
shift
;
# return if $CONNECTOR->dbh->{Driver}{Name} !~ /mysql/i;
...
...
@@ -1769,6 +1793,8 @@ sub _upgrade_tables {
$self
->
_upgrade_table
('
messages
','
date_changed
','
timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
');
$self
->
_upgrade_table
('
grant_types
',
'
is_int
',
'
int DEFAULT 0
');
$self
->
_upgrade_users_table
();
}
sub
_upgrade_timestamps
($self) {
...
...
script/rvd_front
View file @
e46531cf
...
...
@@ -181,7 +181,7 @@ hook before_routes => sub {
return if $url =~ m{^/anonymous};
if ((defined $USER)
&&
(_logged_in($c))
&&
($USER->password_will_be_changed())) {
if ((defined $USER)
&&
(_logged_in($c))
&&
(! $USER->is_temporary)
&&
(! $USER->is_external)
&&
($USER->password_will_be_changed())) {
return change_password($c, 1);
}
...
...
@@ -2297,6 +2297,9 @@ sub change_password {
return $c->render(text => "User is temporary")
if $USER->is_temporary;
return $c->render(text => "User is external")
if $USER->is_external;
my $old_password = $c->param('old_password');
if ($old_password) {
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment