OSDN Git Service

fix initial page
[pettanr/pettanr.git] / app / assets / javascripts / views / users / index.js.coffee
index b2d5fc5..878b4f4 100644 (file)
@@ -14,22 +14,11 @@ class Pettanr.Views.User.Index extends Backbone.View
   sign_in: () ->\r
     m = $('#user_email').val()\r
     p = $('#user_password').val()\r
-    user = new Backbone.Model()\r
-    user.url = '/users/sign_in'\r
-    user.save({user: {email: m, password: p}}, {\r
-      success: (model, response, options) ->\r
-        author = new Pettanr.Author(user.get('author')) if user.get('author')\r
-        artist = new Pettanr.Artist(user.get('artist')) if user.get('artist')\r
-        window.operators = new Pettanr.Operator({\r
-          user: user, \r
-          author: author, \r
-          artist: artist\r
-        })\r
-        r = new Pettanr.Views.Top.Account({operators: window.operators})\r
-        $('#account').html(r.render().el)\r
-        window.router.navigate('', true)\r
-      error: (model, response, options) ->\r
-        response.status\r
-    })\r
+    user = new Pettanr.User.Current()\r
+    user.save({user: {email: m, password: p}}, (current_user) ->\r
+      r = new Pettanr.Views.Top.Account({operators: window.operators})\r
+      $('#account').html(r.render().el)\r
+      window.router.home()\r
+    )\r
     return false\r
   \r