#!/usr/bin/perl
use strict;
use lib './lib';
use Web::Authenticate::User::Storage::Handler::SQL;
use Web::Authenticate::Session::Storage::Handler::SQL;
use Web::Authenticate::User;
use DBIx::Raw;
exit;

my $dbix_raw = DBIx::Raw->new(dsn => 'dbi:mysql:test:127.0.0.1:3306', user => 'root', password => 'forget1');
my $user_sh = Web::Authenticate::User::Storage::Handler::SQL->new(dbix_raw => $dbix_raw, columns => [qw/age/]);
my $storage_handler = Web::Authenticate::Session::Storage::Handler::SQL->new(dbix_raw => $dbix_raw, columns => [qw/session_data/], user_storage_handler => $user_sh);


my $user = Web::Authenticate::User->new(id => 1, row => {});
#$storage_handler->invalidate_user_sessions($user);
#exit;
my $session = $storage_handler->store_session($user, 'session_id', 1234, {session_data =>'session_data'});
exit;
#
#
#$storage_handler->update_expires('session_id', '12345');
#exit;
#my $session = $storage_handler->load_session('yo');
my $session = $storage_handler->delete_session('Z2G5Sv1qMvbQK6gXQT7KBS7Da5PDQi70xEq9LRvQ5Vq');

print $session->id;
print "\n";

print $session->expires;
print "\n";

print $session->user->id;
print "\n";

print $session->user->row->{age};
print "\n";

print $session->row->{session_data};
print "\n";
