Fix legacy login

[?]
Jul 9, 2013, 11:55 AM
PFB5ZUQWW67FRYY54QGTAVTWYMUKXLXRA2XCY3IWK6HZNE6DDLFAC

Dependencies

  • [2] XUKHBDR5 Prevent Persona users from setting a password
  • [3] LC64D4PU Correctly redirect to the referring page when logging in
  • [4] LZVO64YG Merge in the first bits of the API work
  • [5] XMB4MTRL Show sign in as success
  • [6] JARRBLZD Bootstrapify the Hydra forms (except the project and jobset edit pages)
  • [7] 7KF7YZDR Disable account creation for now
  • [8] RU7AQO7U * Role-based access control. Only admins can create projects. Only
  • [9] OEPUOUNB Using twitter bootstrap for more consistent looks for Hydra
  • [10] 2CZSW5S5 Don't redirect to /login if authentication is required
  • [11] XJRJ4J7M Add user registration
  • [12] 36ZTCZ4F Add basic Persona support
  • [13] QL55ECJ6 - adapted ui for hydra, more in line with nixos.org website
  • [14] J5UVLXOK * Start of a basic Catalyst web interface.

Change contents

  • edit in src/lib/Hydra/Controller/User.pm at line 61
    [3.1331]
    [3.1331]
    $c->flash->{flashMsg} = "You are no longer signed in." if $c->user_exists();
  • replacement in src/lib/Hydra/Controller/User.pm at line 63
    [3.1347][3.24646:24820](),[3.24820][3.1417:1420](),[3.1417][3.1417:1420](),[3.1420][3.24821:24930]()
    if ($c->request->looks_like_browser) {
    $c->response->redirect($c->request->referer || $c->uri_for('/'));
    } else {
    $self->status_no_content($c);
    }
    }
    sub logout_GET {
    # Probably a better way to do this
    my ($self, $c) = @_;
    logout_POST($self, $c);
    [3.1347]
    [3.24930]
    $self->status_no_content($c);
  • replacement in src/lib/Hydra/Controller/User.pm at line 101
    [3.1113][2.21:120](),[3.82][3.259:488](),[2.120][3.259:488](),[3.259][3.259:488]()
    $c->flash->{successMsg} = "You are now signed in as <tt>" . encode_entities($email) . "</tt>";
    }
    sub persona_logout :Path('/persona-logout') Args(0) {
    my ($self, $c) = @_;
    $c->stash->{json} = {};
    requirePost($c);
    $c->flash->{flashMsg} = "You are no longer signed in." if $c->user_exists();
    $c->logout;
    [3.1113]
    [3.1113]
    $c->flash->{successMsg} = "You are now signed in as <tt>" . encode_entities($email) . "</tt>.";
  • edit in src/root/layout.tt at line 104
    [3.11729][3.1257:1323]()
    <script src="https://login.persona.org/include.js"></script>
  • replacement in src/root/layout.tt at line 106
    [3.1337][3.1337:1899](),[3.1899][3.828:1049](),[3.1049][3.2148:2168](),[3.2148][3.2148:2168]()
    navigator.id.watch({
    loggedInUser: [% c.user_exists ? '"' _ HTML.escape(c.user.username) _ '"' : "null" %],
    onlogin: function(assertion) {
    $.post("[% c.uri_for('/persona-login') %]", { assertion: assertion })
    .done(function(data) {
    if (data.error)
    bootbox.alert("Login failed: " + data.error);
    else
    window.location.reload();
    })
    .fail(function() { bootbox.alert("Server request failed!"); });
    },
    onlogout: function() {
    $.post("[% c.uri_for('/persona-logout') %]")
    .done(function(data) {
    window.location.reload();
    })
    .fail(function() { bootbox.alert("Server request failed!"); });
    }
    });
    [3.1337]
    [3.7485]
    function doLogout() {
    $.post("[% c.uri_for('/logout') %]")
    .done(function(data) {
    window.location.reload();
    })
    .fail(function() { bootbox.alert("Server request failed!"); });
    }
    </script>
  • replacement in src/root/layout.tt at line 115
    [3.7486][3.2169:2257]()
    $("#persona-signin").click(function() {
    navigator.id.request();
    });
    [3.7486]
    [3.2257]
    [% IF c.user_exists && c.user.password != '!' %]
    <script>
    $("#persona-signout").click(doLogout);
    </script>
    [% ELSE %]
    <script src="https://login.persona.org/include.js"></script>
  • replacement in src/root/layout.tt at line 122
    [3.2258][3.2258:2360]()
    $("#persona-signout").click(function() {
    navigator.id.logout();
    });
    </script>
    [3.2258]
    [3.2360]
    <script>
    navigator.id.watch({
    loggedInUser: [% c.user_exists ? '"' _ HTML.escape(c.user.username) _ '"' : "null" %],
    onlogin: function(assertion) {
    $.post("[% c.uri_for('/persona-login') %]", { assertion: assertion })
    .done(function(data) {
    if (data.error)
    bootbox.alert("Login failed: " + data.error);
    else
    window.location.reload();
    })
    .fail(function() { bootbox.alert("Server request failed!"); });
    },
    onlogout: doLogout
    });
  • edit in src/root/layout.tt at line 138
    [3.2361]
    [3.11729]
    $("#persona-signin").click(function() {
    navigator.id.request();
    });
    $("#persona-signout").click(function() {
    navigator.id.logout();
    });
    </script>
    [% END %]
  • replacement in src/root/login.tt at line 5
    [3.4565][3.9772:9803](),[3.9803][3.4569:4692](),[3.4569][3.4569:4692]()
    <p class="btn-info btn-large">
    You are already logged in as <tt>[% c.user.username %]</tt>.
    You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
    [3.4565]
    [3.4692]
    <p class="alert alert-info">
    You are already signed in as <tt>[% HTML.escape(c.user.username) %]</tt>.
  • edit in src/root/login.tt at line 15
    [3.4409][3.2362:2367]()
    <!--
  • edit in src/root/login.tt at line 38
    [3.5199][3.2368:2372]()
    -->