[Rt-commit] rt branch, 4.0/mobile-login, created. rt-4.0.4-145-g33e7ee8
? sunnavy
sunnavy at bestpractical.com
Wed Dec 14 01:04:24 EST 2011
The branch, 4.0/mobile-login has been created
at 33e7ee8d2f83fda8ae985674809363cba8edaf1e (commit)
- Log -----------------------------------------------------------------
commit 4b2a1399afda5cbc604cd8e43d317693660f4837
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Dec 14 13:27:10 2011 +0800
show mobile login on mobile clients
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 2e8a8f9..b3a2248 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -276,11 +276,18 @@ sub HandleRequest {
# Specially handle /index.html so that we get a nicer URL
elsif ( $m->request_comp->path eq '/index.html' ) {
my $next = SetNextPage(RT->Config->Get('WebURL'));
- $m->comp('/NoAuth/Login.html', next => $next, actions => [$msg]);
+ $m->comp(
+ (MobileClient() && !$ARGS->{NotMobile} ? '/m/login' : '/NoAuth/Login.html'),
+ next => $next,
+ actions => [$msg || ()]
+ );
$m->abort;
}
else {
- TangentForLogin(results => ($msg ? LoginError($msg) : undef));
+ TangentForLogin(
+ results => ( $msg ? LoginError($msg) : undef ),
+ ( MobileClient() && !$ARGS->{NotMobile} ? (mobile => 1) : () ),
+ );
}
}
}
diff --git a/share/html/NoAuth/Login.html b/share/html/NoAuth/Login.html
index b33bb0a..83a4c79 100755
--- a/share/html/NoAuth/Login.html
+++ b/share/html/NoAuth/Login.html
@@ -49,4 +49,9 @@
my ($good, $msg) = RT::Interface::Web::AttemptPasswordAuthentication(\%ARGS);
$ARGS{'actions'} = [$msg] if not $good and $msg;
</%init>
+
+% if ( $ARGS{'mobile'} ) {
+<& /m/login, %ARGS &>
+% } else {
<& /Elements/Login, %ARGS &>
+% }
commit 33e7ee8d2f83fda8ae985674809363cba8edaf1e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Dec 14 13:36:07 2011 +0800
basic login test
diff --git a/t/web/login.t b/t/web/login.t
new file mode 100644
index 0000000..33240f5
--- /dev/null
+++ b/t/web/login.t
@@ -0,0 +1,86 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 21;
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+
+my $ticket = RT::Test->create_ticket(
+ Subject => 'ticket_foo',
+ Queue => 'General',
+);
+
+my ( $user, $pass ) = ( 'root', 'password' );
+
+diag "normal login";
+{
+ $m->get($baseurl);
+ $m->title_is('Login');
+ is( $m->uri, $baseurl, "right url" );
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+
+ $m->title_is( 'RT at a glance', 'logged in' );
+
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+ $m->title_is( 'Logout', 'logout' );
+}
+
+diag "tangent login";
+
+{
+ $m->get( $baseurl . '/Ticket/Display.html?id=1' );
+ $m->title_is('Login');
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ like( $m->uri, qr{/Ticket/Display\.html}, 'normal ticket page' );
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+}
+
+diag "mobile normal login";
+{
+
+ # default browser in android 2.3.6
+ $m->agent(
+"Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus One Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
+ );
+
+ $m->get($baseurl);
+ is( $m->uri, $baseurl, "right url" );
+ $m->content_contains( "/m/index.html?NotMobile=1", 'mobile login' );
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ is( $m->uri, $baseurl . '/m/', "mobile url" );
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+ like( $m->uri, qr{/NoAuth/Login\.html}, 'back to login page' );
+}
+
+diag "mobile tangent login";
+{
+ $m->get( $baseurl . '/Ticket/Display.html?id=1' );
+ $m->content_contains( "/m/index.html?NotMobile=1", 'mobile login' );
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ like( $m->uri, qr{/m/ticket/show}, 'mobile ticket page' );
+}
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list