add smid dump script.
[SMMID.git] / lib / SMMID / Controller / Root.pm
blobb5f7d189b4be25749d0994f90e6ad9afcf4cc55e
1 package SMMID::Controller::Root;
3 use strict;
4 use warnings;
5 use parent 'Catalyst::Controller';
6 use SMMID::Login;
9 # Sets the actions in this controller to be registered with no prefix
10 # so they function identically to actions created in MyApp.pm
12 __PACKAGE__->config->{namespace} = '';
14 =head1 NAME
16 SMMID::Controller::Root - Root Controller for SMMID
18 =head1 DESCRIPTION
20 [enter your description here]
22 =head1 METHODS
24 =cut
26 =head2 index
28 =cut
31 sub auto : Private {
32 my ($self, $c) = @_;
34 # gluecode for logins
36 #unless( $c->config->{'disable_login'} ) {
37 my $login = SMMID::Login->new( { schema => $c->model("SMIDDB")->schema() });
39 if (exists($c->req->cookies->{smmid_session_id})) {
40 $login->cookie_string($c->req->cookies->{smmid_session_id}->value());
43 if ( my $dbuser_id = $login->has_session()) {
45 print STDERR "We have a logged in user! :-)\n";
46 my $dbuser = $c->model("SMIDDB")->resultset("SMIDDB::Result::Dbuser")->find( { dbuser_id => $dbuser_id });
47 print STDERR "The logged in user is ".$dbuser->username()."\n";
49 my $user = SMMID::Authentication::User->new();
50 $c->user($user);
51 $c->user()->set_object($dbuser);
53 # $self->authenticate($c, 'default', {
54 # username => $dbuser->username(),
55 # password => $dbuser->password(),
56 # });
59 return 1;
62 sub index :Path :Args(0) {
63 my ( $self, $c ) = @_;
65 # Hello World
66 $c->stash->{template} = 'index.mas';
69 sub default :Path {
70 my ( $self, $c ) = @_;
71 $c->response->body( 'Page not found' );
72 $c->response->status(404);
76 sub contact :Path('/contact') :Args(0) {
77 my ($self, $c) = @_;
80 sub cite : Path('/cite') Args(0) {
84 sub about :Path('/about') :Args(0) {
85 my ($self, $c) = @_;
88 sub download :Path('/download') Args(0) {
89 my $self = shift;
90 my $c = shift;
92 $c->stash->{template} = '/download.mas';
95 =head2 end
97 Attempt to render a view, if needed.
99 =cut
101 sub end : ActionClass('RenderView') {}
103 =head1 AUTHOR
105 Lukas Mueller,,,
107 =head1 LICENSE
109 This library is free software, you can redistribute it and/or modify
110 it under the same terms as Perl itself.
112 =cut