Use Mojolicious::Plugin::Database to connect to the DB

Fix #86
master
Daniel Berteaud 10 years ago
parent 1c93335ff2
commit cf3e6a28b1
  1. 23
      vroom.pl

@ -8,7 +8,7 @@
use lib '../lib'; use lib '../lib';
use Mojolicious::Lite; use Mojolicious::Lite;
use Mojolicious::Plugin::Mail; use Mojolicious::Plugin::Mail;
use DBI; use Mojolicious::Plugin::Database;
use Crypt::SaltedHash; use Crypt::SaltedHash;
use MIME::Base64; use MIME::Base64;
use File::stat; use File::stat;
@ -205,24 +205,20 @@ plugin I18N => {
support_url_langs => [qw(en fr)] support_url_langs => [qw(en fr)]
}; };
# Connect to the database
plugin database => {
dsn => $config->{dbi},
username => $config->{dbUser},
password => $config->{dbPassword},
options => { mysql_enable_utf8 => 1 }
};
# Load mail plugin with its default values # Load mail plugin with its default values
plugin mail => { plugin mail => {
from => $config->{emailFrom}, from => $config->{emailFrom},
type => 'text/html', type => 'text/html',
}; };
# Wrapper arround DBI
helper db => sub {
my $dbh = DBI->connect($config->{dbi},
$config->{dbUser},
$config->{dbPassword},
{
mysql_enable_utf8 => 1,
}
) || die "Could not connect";
$dbh
};
# Create a cookie based session # Create a cookie based session
helper login => sub { helper login => sub {
my $self = shift; my $self = shift;
@ -850,6 +846,7 @@ helper create_etherpad_session => sub {
my $etherpadCookieParam = {}; my $etherpadCookieParam = {};
if ($config->{etherpadBaseDomain} && $config->{etherpadBaseDomain} ne ''){ if ($config->{etherpadBaseDomain} && $config->{etherpadBaseDomain} ne ''){
$etherpadCookieParam->{domain} = $config->{etherpadBaseDomain}; $etherpadCookieParam->{domain} = $config->{etherpadBaseDomain};
$self->app->log->debug("Creating an etherpad SesionID cookie for domaine " . $config->{etherpadBaseDomain});
} }
$self->cookie(sessionID => $etherpadSession, $etherpadCookieParam); $self->cookie(sessionID => $etherpadSession, $etherpadCookieParam);
}; };

Loading…
Cancel
Save