Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Owned bin urls #554

Merged
merged 5 commits into from Apr 6, 2013

Conversation

Projects
None yet
2 participants
Owner

remy commented Apr 5, 2013

This change means that if you're logged in and you created the first revision, then the url is automatically owned by you (this applies to old bins as well as new bins).

This means if you share the url like http://jsbin.com/abcefg/latest on twitter, anonymous users editing that bin will get their own url, such as http://jsbin.com/zyxwv/1

So, if you've ever shared a url on twitter and wanted to share the latest url, then this will protect the url for unwanted revisions.

Owner

remy commented Apr 5, 2013

Oh, and fixed a few other issues whilst I was at it!

Owner

remy commented Apr 5, 2013

I'll release this at the weekend if all is good. Too late in the evening now to sensibly release this!

@tgvashworth tgvashworth and 1 other commented on an outdated diff Apr 5, 2013

lib/db/sqlite.js
@@ -450,5 +450,23 @@ module.exports = utils.inherit(Object, {
}
fn(null, results);
});
+ },
+ isOwnerOf: function (params, fn) {
+ var values = [
+ params.name,
+ params.url
+ ], sql = templates.isOwnerOf;
+
+ this.connection.run(sql, values, function (err, result) {
+ if (err) {
+ return fn(err);
+ }
+ if (typeof result === 'undefined') {
+ return fn(null, { found: false });
+ } else {
+ return fn(null, { found: true, isowner: result[0].owner === 1 });
@tgvashworth

tgvashworth Apr 5, 2013

Member

This probably needs the same safety checking as the MySQL version? (isowner: result.length ? result[0].owner === 1 : false)

@remy

remy Apr 6, 2013

Owner

Actually, IIRC if the length is zero, then the result is undefined, so if we're in that line, there will be an array of results. Not terribly clear though - since you'd expect it to be the same as the mysql version.

@remy

remy Apr 6, 2013

Owner

(that said, a test wouldn't be amiss)

remy added a commit that referenced this pull request Apr 6, 2013

@remy remy merged commit ca0296f into master Apr 6, 2013

@remy remy deleted the feature/ownedbins branch Apr 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment