diff --git a/site/client/app/modules/session/components/register.js b/site/client/app/modules/session/components/register.js index 56261c9..23429cd 100644 --- a/site/client/app/modules/session/components/register.js +++ b/site/client/app/modules/session/components/register.js @@ -18,8 +18,23 @@ module.exports = { if( ! this.username || ! this.password || ! this.email) { $('.form-error').hide().fadeIn('fast'); + + return false; } + $('.form-error').hide(); + $('.icon-action-load').show(); + + this.$http.post('./api/register', this.$data, function(data) { + + location.reload(); + + }).error(function (data) { + + $('.icon-action-load').hide(); + + }) + return false; } } diff --git a/site/client/assets/sass/_form.scss b/site/client/assets/sass/_form.scss index 9704f19..7766137 100644 --- a/site/client/assets/sass/_form.scss +++ b/site/client/assets/sass/_form.scss @@ -1,5 +1,5 @@ -.icon-load { - background: url(../img/load.gif) no-repeat; +.icon-action-load { + background: url(../img/action-load.gif) no-repeat; width: 16px; height: 16px; float: right; diff --git a/site/server/app/Http/routes.php b/site/server/app/Http/routes.php index cde57ef..25f74f8 100755 --- a/site/server/app/Http/routes.php +++ b/site/server/app/Http/routes.php @@ -1,5 +1,23 @@ 'api'], function() { + + post('/register', function() { + $user = new User(); + $user->username = Request::input('username'); + $user->email = Request::input('email'); + $user->password = bcrypt(Request::input('password')); + $user->save(); + + Auth::login($user); + }); + + }); + get('/lobby', function() { return innerView(); });