|
|
@ -73,6 +73,9 @@ if ($config->{'etherpad.uri'} =~ m/https?:\/\/.*/ && $config->{'etherpad.api_key |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# GLobal error check |
|
|
|
|
|
|
|
our $error = undef; |
|
|
|
|
|
|
|
|
|
|
|
# Load I18N, and declare supported languages |
|
|
|
# Load I18N, and declare supported languages |
|
|
|
plugin I18N => { |
|
|
|
plugin I18N => { |
|
|
|
namespace => 'Vroom::I18N', |
|
|
|
namespace => 'Vroom::I18N', |
|
|
@ -137,6 +140,21 @@ helper valid_email => sub { |
|
|
|
# Various helpers # |
|
|
|
# Various helpers # |
|
|
|
########################## |
|
|
|
########################## |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if the database schema is the one we expect |
|
|
|
|
|
|
|
helper check_db_version => sub { |
|
|
|
|
|
|
|
my $self = shift; |
|
|
|
|
|
|
|
my $sth = eval { |
|
|
|
|
|
|
|
$self->db->prepare('SELECT `value` |
|
|
|
|
|
|
|
FROM `config` |
|
|
|
|
|
|
|
WHERE `key`=\'schema_version\''); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
$sth->execute; |
|
|
|
|
|
|
|
my $ver = undef; |
|
|
|
|
|
|
|
$sth->bind_columns(\$ver); |
|
|
|
|
|
|
|
$sth->fetch; |
|
|
|
|
|
|
|
return ($ver eq Vroom::Constants::DB_VERSION) ? '1' : '0'; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
# Create a cookie based session |
|
|
|
# Create a cookie based session |
|
|
|
helper login => sub { |
|
|
|
helper login => sub { |
|
|
|
my $self = shift; |
|
|
|
my $self = shift; |
|
|
@ -1962,14 +1980,21 @@ app->hook(before_dispatch => sub { |
|
|
|
$self->stash(config => $config); |
|
|
|
$self->stash(config => $config); |
|
|
|
|
|
|
|
|
|
|
|
# Check db is available |
|
|
|
# Check db is available |
|
|
|
if (!$self->db){ |
|
|
|
if ($error){ |
|
|
|
$self->app->log->info("Connect connect to the database"); |
|
|
|
|
|
|
|
return $self->render('error', |
|
|
|
return $self->render('error', |
|
|
|
msg => $self->l('ERROR_DB_UNAVAILABLE'), |
|
|
|
msg => $self->l($error), |
|
|
|
err => 'ERROR_DB_UNAVAILABLE' |
|
|
|
err => $error, |
|
|
|
|
|
|
|
room => '' |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!app->db){ |
|
|
|
|
|
|
|
$error = 'ERROR_DB_UNAVAILABLE'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!app->check_db_version){ |
|
|
|
|
|
|
|
$error = 'ERROR_DB_VERSION_MISMATCH'; |
|
|
|
|
|
|
|
} |
|
|
|
# Are we running in hypnotoad ? |
|
|
|
# Are we running in hypnotoad ? |
|
|
|
app->config( |
|
|
|
app->config( |
|
|
|
hypnotoad => { |
|
|
|
hypnotoad => { |
|
|
|