From 976bdace6704b60bc984635917ee56f17797c10a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 3 Sep 2015 16:35:07 -0400 Subject: able to log in --- public/assets/js/lib/router.js | 9 ++------- public/assets/js/lib/views/login/login.js | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'public/assets/js/lib') diff --git a/public/assets/js/lib/router.js b/public/assets/js/lib/router.js index 30646c1..5bc05c3 100644 --- a/public/assets/js/lib/router.js +++ b/public/assets/js/lib/router.js @@ -5,19 +5,14 @@ var SiteRouter = Router.extend({ el: "body", routes: { - "/": 'lobby', + "/": 'login', "/index": 'index', "/login": 'login', "/details/:id": 'room', }, initialize: function(){ - if (! user.username) { - app.view = new LoginView() - } - else { - this.route() - } + this.route() }, index: function(){ diff --git a/public/assets/js/lib/views/login/login.js b/public/assets/js/lib/views/login/login.js index 06d8808..a48b404 100644 --- a/public/assets/js/lib/views/login/login.js +++ b/public/assets/js/lib/views/login/login.js @@ -1,14 +1,26 @@ var LoginView = FormView.extend({ - - events: { - }, + + el: "#login", + action: "/api/login", + method: "POST", initialize: function(opt){ - // opt.parent = parent + this.__super__.initialize.call(this) + this.$("[name=username]").focus() + }, + + showErrors: function(errors){ + console.log(errors) }, - success: function(){ - window.location.href = "/index" + success: function(data){ + console.log(data) + if (data.returnTo) { + window.location.href = "/index" + } + else { + window.location.href = "/index" + } }, -}) \ No newline at end of file +}) -- cgit v1.2.3-70-g09d2