miguelfreitas / twister-html

twister HTML + Javascript User Interface
MIT License
229 stars 138 forks source link

Fix the problem defaultScreenName can be stored as Number #342

Closed kissge closed 8 years ago

kissge commented 8 years ago

$.localStorage.set can interpret the second argument as a JSON string, so:

$.localStorage.set("foo", "1234");
$.localStorage.get("foo"); // => 1234
typeof $.localStorage.get("foo"); // => "number"

This prevents users whose screen name consists only digits (like @928) from logging in because his/her screen name doesn't match with the stored user name (https://github.com/miguelfreitas/twister-html/blob/8394d8f0f22f7bf2305ca9326d23e003968512b9/js/twister_user.js#L31).

['928'].indexOf(928); // => -1

By merging this pull request, the stored value is assured to be a string value, which fixes this problem.

slr commented 8 years ago

cool! but what if to apply .toString() on defaultScreenName assignment instead?

kissge commented 8 years ago

That might be better! Should I squash the commit? (btw I also reported this as a bug to jQuery localStorage plugin repo)

slr commented 8 years ago

Should I squash the commit?

if you don't mind. and of course I want new pull request from you to fix the issue finally.