parent
5e9ccf605f
commit
11fecbd7ae
@ -0,0 +1,69 @@
|
||||
package NGCP::Panel::Controller::Login;
|
||||
use Moose;
|
||||
use namespace::autoclean;
|
||||
|
||||
BEGIN { extends 'Catalyst::Controller'; }
|
||||
|
||||
=head1 NAME
|
||||
|
||||
NGCP::Panel::Controller::Login - Catalyst Controller
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Catalyst Controller.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
=head2 index
|
||||
|
||||
=cut
|
||||
|
||||
sub index :Path {
|
||||
my ( $self, $c, $realm ) = @_;
|
||||
|
||||
$c->log->debug("*** Login::index");
|
||||
|
||||
my $user = $c->req->params->{username};
|
||||
my $pass = $c->req->params->{password};
|
||||
|
||||
$realm = 'subscriber'
|
||||
unless($realm and ($realm eq 'admin' or $realm eq 'reseller'));
|
||||
|
||||
if($user and $pass) {
|
||||
$c->log->debug("*** Login::index user=$user, pass=$pass, realm=$realm");
|
||||
if($c->authenticate({ username => $user, password => $pass }, $realm)) {
|
||||
# auth ok
|
||||
my $target = $c->session->{'target'} || '/';
|
||||
delete $c->session->{target};
|
||||
$c->log->debug("*** Login::index auth ok, redirecting to $target");
|
||||
$c->response->redirect($target);
|
||||
} else {
|
||||
$c->log->debug("*** Login::index auth failed");
|
||||
}
|
||||
} else {
|
||||
$c->log->debug("*** Login::index incomplete creds");
|
||||
}
|
||||
|
||||
$c->stash(realm => $realm);
|
||||
$c->stash(template => 'login.tt');
|
||||
}
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Andreas Granig,,,
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This library is free software. You can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
|
||||
1;
|
||||
# vim: set tabstop=4 expandtab:
|
@ -0,0 +1,46 @@
|
||||
package NGCP::Panel::Controller::Logout;
|
||||
use Moose;
|
||||
use namespace::autoclean;
|
||||
|
||||
BEGIN { extends 'Catalyst::Controller'; }
|
||||
|
||||
=head1 NAME
|
||||
|
||||
NGCP::Panel::Controller::Logout - Catalyst Controller
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Catalyst Controller.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
=head2 index
|
||||
|
||||
=cut
|
||||
|
||||
sub index :Path {
|
||||
my ( $self, $c, $realm ) = @_;
|
||||
|
||||
$c->logout;
|
||||
$c->response->redirect($c->uri_for('/login'));
|
||||
}
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Andreas Granig,,,
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This library is free software. You can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
|
||||
1;
|
||||
# vim: set tabstop=4 expandtab:
|
@ -0,0 +1,56 @@
|
||||
<body class="login">
|
||||
<div class="account-container login stacked">
|
||||
<div class="content clearfix">
|
||||
<form method="post" action="[% c.uri_for("/login/$realm") %]" novalidate="novalidate">
|
||||
<h1>Sign In</h1>
|
||||
<div class="login-fields">
|
||||
<p>Sign in with your [% realm %] credentials:</p>
|
||||
<div class="field">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-actions">
|
||||
<span class="login-checkbox">
|
||||
<input id="Field" name="Field" type="checkbox" class="field login-checkbox" value="First Choice" tabindex="4" />
|
||||
<label class="choice" for="Field">Keep me signed in</label>
|
||||
</span>
|
||||
<button class="button btn btn-primary btn-large">Sign In</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
[% IF realm == 'subscriber' -%]
|
||||
<div class="login-extra">
|
||||
Go to
|
||||
<a href="[% c.uri_for('/login/admin') %]">Admin</a> or
|
||||
<a href="[% c.uri_for('/login/reseller') %]">Reseller</a>
|
||||
login.<br/>
|
||||
</div>
|
||||
[% END -%]
|
||||
|
||||
[%#
|
||||
TODO: load this only if a signup plugin is installed
|
||||
<div class="login-extra">
|
||||
Don't have an account? <a href="signup.html">Sign Up</a><br/>
|
||||
</div>
|
||||
%]
|
||||
|
||||
<script src="/js/libs/jquery-1.7.2.min.js"></script>
|
||||
<script src="/js/libs/jquery-ui-1.8.21.custom.min.js"></script>
|
||||
<script src="/js/libs/jquery.ui.touch-punch.min.js"></script>
|
||||
<script src="/js/libs/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="/js/Theme.js"></script>
|
||||
<script src="/js/signin.js"></script>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
Theme.init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
[% # vim: set tabstop=4 syntax=html expandtab: -%]
|
@ -0,0 +1,10 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
|
||||
|
||||
use Catalyst::Test 'NGCP::Panel';
|
||||
use NGCP::Panel::Controller::Login;
|
||||
|
||||
ok( request('/login')->is_success, 'Request should succeed' );
|
||||
done_testing();
|
Loading…
Reference in new issue