Skip to content

Commit

Permalink
Changing /logout such that it works without being a protected route
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Sep 18, 2014
1 parent 0182190 commit 4dc3e9e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 0.9.4
- Changing `/logout` such that it works without being a protected route

## 0.9.3
- Made `hypermedia()` smartr by not mutating the result when it's an Array of URIs, for obvious data modeling issues!

Expand Down
2 changes: 1 addition & 1 deletion doc/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ <h5>Returns:</h5>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2014-09-18T07:45:25-04:00 using the <a
on 2014-09-18T08:04:49-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ <h2>License</h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2014-09-18T07:45:25-04:00 using the <a
on 2014-09-18T08:04:49-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
4 changes: 2 additions & 2 deletions doc/module-tenso.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ <h2>
<dt class="tag-version">Version:</dt>
<dd class="tag-version">
<ul class="dummy">
<li>0.9.3</li>
<li>0.9.4</li>
</ul>
</dd>

Expand Down Expand Up @@ -218,7 +218,7 @@ <h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2014-09-18T07:45:25-04:00 using the <a
on 2014-09-18T08:04:50-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
2 changes: 1 addition & 1 deletion doc/modules.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ <h2>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on 2014-09-18T07:45:25-04:00 using the <a
on 2014-09-18T08:04:49-04:00 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
Expand Down
12 changes: 6 additions & 6 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* @license BSD-3 <https://raw.github.com/avoidwork/tenso/master/LICENSE>
* @link http://avoidwork.github.io/tenso
* @module tenso
* @version 0.9.3
* @version 0.9.4
*/
( function () {
"use strict";

var turtleio = require( "turtle.io" ),
SERVER = "tenso/0.9.3",
SERVER = "tenso/0.9.4",
CONFIG = require( __dirname + "/../config.json" ),
keigai = require( "keigai" ),
util = keigai.util,
Expand Down Expand Up @@ -63,7 +63,7 @@ function Tenso () {
this.rates = {};
this.server = turtleio();
this.server.tenso = this;
this.version = "0.9.3";
this.version = "0.9.4";
}

/**
Expand Down Expand Up @@ -327,14 +327,14 @@ function auth ( obj, config ) {
obj.server.use( regex, guard ).blacklist( guard );
} )();

config.routes.get["/login"] = config.auth.local.enabled ? ( keys ? {login_uri: "/auth", instruction: "POST username/password to authenticate"} : {instruction: "POST username/password to authenticate"} ) : {login_uri: "/auth"};
config.routes.get["/login"] = config.auth.local.enabled ? ( keys ? {login_uri: "/auth", instruction: "POST 'username' & 'password' to authenticate"} : {instruction: "POST 'username' & 'password' to authenticate"} ) : {login_uri: "/auth"};
}
else if ( config.auth.local.enabled ) {
config.routes.get["/login"] = {instruction: "POST username/password to authenticate"};
config.routes.get["/login"] = {instruction: "POST 'username' & 'password' to authenticate"};
}

config.routes.get["/logout"] = function ( req, res ) {
if ( req.session.isAuthorized() ) {
if ( req.session ) {
req.session.destroy();
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is a REST API facade for node.js, designed to simplify the implementation of APIs.",
"version": "0.9.3",
"version": "0.9.4",
"homepage": "http://avoidwork.github.io/tenso",
"author": {
"name": "Jason Mulligan",
Expand Down
6 changes: 3 additions & 3 deletions src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ function auth ( obj, config ) {
obj.server.use( regex, guard ).blacklist( guard );
} )();

config.routes.get["/login"] = config.auth.local.enabled ? ( keys ? {login_uri: "/auth", instruction: "POST username/password to authenticate"} : {instruction: "POST username/password to authenticate"} ) : {login_uri: "/auth"};
config.routes.get["/login"] = config.auth.local.enabled ? ( keys ? {login_uri: "/auth", instruction: "POST 'username' & 'password' to authenticate"} : {instruction: "POST 'username' & 'password' to authenticate"} ) : {login_uri: "/auth"};
}
else if ( config.auth.local.enabled ) {
config.routes.get["/login"] = {instruction: "POST username/password to authenticate"};
config.routes.get["/login"] = {instruction: "POST 'username' & 'password' to authenticate"};
}

config.routes.get["/logout"] = function ( req, res ) {
if ( req.session.isAuthorized() ) {
if ( req.session ) {
req.session.destroy();
}

Expand Down
2 changes: 1 addition & 1 deletion test/tenso_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ describe("Local", function () {
.get("/login")
.expectStatus(200)
.expectValue("data.link", [{uri: "http://localhost:" + port, rel: "collection"}] )
.expectValue("data.result", {instruction: "POST username/password to authenticate"} )
.expectValue("data.result", {instruction: "POST 'username' & 'password' to authenticate"} )
.expectValue("error", null)
.expectValue("status", 200)
.end(function(err) {
Expand Down

0 comments on commit 4dc3e9e

Please sign in to comment.