diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in index 7e12682b88cf0531a791b2d5d85ef394f17bc900..04f06dba7b44f30a763a0ee61e20fb443ca5ab77 100755 --- a/bin/account-manager.pl.in +++ b/bin/account-manager.pl.in @@ -103,8 +103,8 @@ sub add_account { scope => $configuration->{idp}->{scope}, password => $password, password_hash => AccountManager::Tools::sha256_hash($password), - creation_date => DateTime->today(), - expiration_date => DateTime->today()->add(days => $validity_period) + creation_date => DateTime->now(), + expiration_date => DateTime->now()->add(days => $validity_period) ); die "Failed to save test account\n" @@ -329,8 +329,8 @@ sub add_token { db => $db, email_address => $options{email_address}, sp_entityid => $options{sp_entityid}, - creation_date => DateTime->today(), - expiration_date => DateTime->today()->add(hours => $validity_period), + creation_date => DateTime->now(), + expiration_date => DateTime->now()->add(hours => $validity_period), token => AccountManager::Tools::generate_token() ); diff --git a/conf/create-manager-db.sql b/conf/create-manager-db.sql index 908ab0ea1d80d7ffa8bd5ef15f05ca78b2f95c47..43158aa5434bbc192f043b6783a8b74cc3d541d7 100644 --- a/conf/create-manager-db.sql +++ b/conf/create-manager-db.sql @@ -11,8 +11,8 @@ CREATE TABLE `tokens` ( `token` varchar(50) NOT NULL, `email_address` varchar(200) NOT NULL, `sp_entityid` varchar(200) NOT NULL, - `creation_date` date DEFAULT NULL, - `expiration_date` date DEFAULT NULL, + `creation_date` datetime DEFAULT NULL, + `expiration_date` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `token_2` (`token`), KEY `token` (`token`), @@ -31,8 +31,8 @@ CREATE TABLE `services` ( CREATE TABLE `accounts` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `password_hash` varchar(50) NOT NULL, - `creation_date` date DEFAULT NULL, - `expiration_date` date DEFAULT NULL, + `creation_date` datetime DEFAULT NULL, + `expiration_date` datetime DEFAULT NULL, `profile` varchar(100) NOT NULL, `scope` varchar(100) NOT NULL, `sp_entityid` varchar(250) NOT NULL, diff --git a/lib/AccountManager/Account.pm b/lib/AccountManager/Account.pm index 7052eb827430eee12e323a0086fd02d6a59833cc..4c329f047db0b0c37b92de568f9f7be63de756e3 100644 --- a/lib/AccountManager/Account.pm +++ b/lib/AccountManager/Account.pm @@ -12,8 +12,8 @@ __PACKAGE__->meta->setup( id => { type => 'bigserial', not_null => 1 }, password_hash => { type => 'varchar', length => 50, not_null => 1 }, password => { type => 'varchar', length => 50, nonpersistent => 1 }, - creation_date => { type => 'date' }, - expiration_date => { type => 'date' }, + creation_date => { type => 'datetime' }, + expiration_date => { type => 'datetime' }, profile => { type => 'varchar', length => 100, not_null => 1 }, scope => { type => 'varchar', length => 100, not_null => 1 }, sp_entityid => { type => 'varchar', length => 250, not_null => 1 }, diff --git a/lib/AccountManager/Token.pm b/lib/AccountManager/Token.pm index b44bc5f7f5f09c47b8b8f8eea091b4c6939bf7fd..5e4a944e8f5fe6b141254964d767273854f31c37 100644 --- a/lib/AccountManager/Token.pm +++ b/lib/AccountManager/Token.pm @@ -13,8 +13,8 @@ __PACKAGE__->meta->setup( token => { type => 'varchar', length => 50, not_null => 1 }, email_address => { type => 'varchar', length => 200, not_null => 1 }, sp_entityid => { type => 'varchar', length => 200, not_null => 1 }, - creation_date => { type => 'date' }, - expiration_date => { type => 'date' }, + creation_date => { type => 'datetime' }, + expiration_date => { type => 'datetime' }, ], primary_key_columns => [ 'id' ], @@ -35,8 +35,8 @@ sub print { $self->token(), $self->email_address(), $self->sp_entityid(), - $self->creation_date()->strftime('%Y:%m:%d'), - $self->expiration_date()->strftime('%Y:%m:%d'); + $self->creation_date()->strftime('%Y:%m:%d %H:%M'), + $self->expiration_date()->strftime('%Y:%m:%d %H:%M'); } 1; diff --git a/lib/AccountManager/WebRequest.pm b/lib/AccountManager/WebRequest.pm index 2f4cf5492a43fce56dde07976e06f9cfcf34b9ef..0447fe1d992297fd14e29d525248d52ff203afa7 100644 --- a/lib/AccountManager/WebRequest.pm +++ b/lib/AccountManager/WebRequest.pm @@ -345,8 +345,8 @@ sub req_generate_token { db => $self->{db}, email_address => $self->{in}->{email_address}, sp_entityid => $self->{in}->{sp_entityid}, - creation_date => DateTime->today(), - expiration_date => DateTime->today()->add(hours => $validity_period), + creation_date => DateTime->now(), + expiration_date => DateTime->now()->add(hours => $validity_period), token => AccountManager::Tools::generate_token() ); @@ -480,8 +480,8 @@ sub req_validate_token { scope => $self->{configuration}->{idp}->{scope}, password => $password, password_hash => AccountManager::Tools::sha256_hash($password), - creation_date => DateTime->today(), - expiration_date => DateTime->today()->add(days => $validity_period) + creation_date => DateTime->now(), + expiration_date => DateTime->now()->add(days => $validity_period) ); next unless $account->save(); push @accounts, $account;