sqlitebrowser / dbhub.io

A "Cloud" for SQLite databases. Collaborative development for your data. 😊
https://dbhub.io
GNU Affero General Public License v3.0
372 stars 39 forks source link

[Newbie Thoughts] Username fails validation #82

Open chrisjlocke opened 7 years ago

chrisjlocke commented 7 years ago

Creating a wacky username fails validation, but the user doesn't know why.

image

This one could be a nice simple one for me to play with as the code to fail is already there - just needs a 'heres why, knobby' text added. Maybe.... ?

justinclift commented 7 years ago

Yep, that'd definitely be useful. :smile:

The code which does that is this:

It might seem (probably deceptively) simple. :wink:

The concept is obviously straight forward:

  1. the javascript on the front end sends a potential username to the server
  2. the server runs a few checks, then returns 'y' or 'n' to indicate success or failure
  3. the javascript then figures out what to show

The 'y' or 'n' thing is because when writing that code I didn't (at the time) understand how to send http status codes from the server back to the browser. Thus sending y/n instead.

To make this a much nicer experience for the user, it'd probably need these bits to be done:

  1. Update the server side to send a useful status message + use http status code to indicate success or failure (instead of the y/n thing)
  2. Update the browser side to grok and display the useful status message sent
  3. (this bit could be more tricky) Adjust the server side validation and/or ReservedUsernamesCheck() check code to return better info, so the above two pieces have something to work with.

On that note, do you have Go 1.9 and Gogland installed? :smile:

chrisjlocke commented 7 years ago

On that note, do you have Go 1.9 and Gogland installed?

Hopefully by the time you read this.

Adjust the server side validation and/or ReservedUsernamesCheck() check code to return better info,

The beauty of status codes. I assume (for example) return 450 which means invalid length, 451 which means it contains a + (or invalid characters, but denoting which one is useful) 452 for ...... etc.

The code which does that is this

Thanks for the pointers. useful for starting. 👍

justinclift commented 7 years ago

... and now I realise you're going to need to set up a running local dbhub.io server.

Probably about time I started writing those long overdue "How to setup and run your own dbhub.io server" docs. Maybe starting with just the bare essentials first. :smile:

justinclift commented 7 years ago

Oh... and on Windows too. This could be fun.

justinclift commented 7 years ago

Looking through our dependencies list, we rely on these bits of software:

You might need to run Memcached in a VM of some sort if it turns out to really not like Windows. Alternatively, I can pretty easily setup a new Memcached VM online and update its firewall so only you can connect to it. We literally have a working memcached server image ready to go in Rackspace that I'd just need to spin up and change some IP info for. :smile:

justinclift commented 7 years ago

The beauty of status codes. I assume (for example) return 450 which means invalid length, 451 which means it contains a + (or invalid characters, but denoting which one is useful) 452 for ...... etc.

Yep. I'm not an expert on them, more a "lets get it working ok first"-pert. So... err... get it working "however you can", and we can refine it from there? :smile:

chrisjlocke commented 7 years ago

I'm ... more a "lets get it working ok first"-pert.

image