Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CSRF絡みの登録処理の不具合を修正

  • Loading branch information...
commit e2903e5e245c87f57e84287bbb109ed9e755f22c 1 parent 60ef5ec
@nsyee00 nsyee00 authored
Showing with 70 additions and 55 deletions.
  1. +10 −10 app.js
  2. +2 −2 lib/controllers/chatroom.js
  3. +1 −1  lib/controllers/mypage.js
  4. +1 −1  lib/controllers/socketIo.js
  5. +2 −1  lib/controllers/user.js
  6. +9 −1 lib/middleware/index.js
  7. +2 −0  lib/utils/index.js
  8. +4 −0 lib/utils/mail.js
  9. +3 −3 public/js/dist/chatroom.js
  10. +1 −1  public/js/dist/chatroom.min.js
  11. +2 −2 public/js/dist/createChatroom.js
  12. +1 −1  public/js/dist/createChatroom.min.js
  13. +2 −2 public/js/dist/deactivation.js
  14. +1 −1  public/js/dist/deactivation.min.js
  15. +2 −2 public/js/dist/deleteChatroom.js
  16. +1 −1  public/js/dist/deleteChatroom.min.js
  17. +2 −2 public/js/dist/mypage.js
  18. +1 −1  public/js/dist/mypage.min.js
  19. +2 −2 public/js/dist/register.js
  20. +1 −1  public/js/dist/register.min.js
  21. +3 −3 public/js/views/chat.js
  22. +2 −2 public/js/views/createChatroom.js
  23. +2 −2 public/js/views/deactivation.js
  24. +2 −2 public/js/views/deleteChatroom.js
  25. +2 −2 public/js/views/mypage.js
  26. +2 −2 public/js/views/register.js
  27. +1 −1  views/chatroom.ejs
  28. +2 −2 views/createChatroom.ejs
  29. +1 −1  views/deactivation.ejs
  30. +1 −1  views/deleteChatroom.ejs
  31. +1 −1  views/mypage.ejs
  32. +1 −1  views/register.ejs
View
20 app.js
@@ -77,7 +77,7 @@ app.configure(function() {
app.use(express.session({
key: 'sess_id',
cookie: {
- maxAge: config.server.cookieMaxAge, // 1week
+ maxAge: config.server.cookieMaxAge,
secure: true
},
store: sessionStore
@@ -85,22 +85,22 @@ app.configure(function() {
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
+ // SSL通信を強制
app.use(middleware.ssl);
+ // セッションデータをejsからアクセスできるように設定
app.use(middleware.sessionData);
+ // 環境変数をejsからアクセスできるように設定
app.use(middleware.envData);
+ // 設定ファイルをejsからアクセスできるように設定
app.use(middleware.configData);
+ app.use(express.compress());
+ app.use(express.csrf()); // この位置じゃないと動かない?順番要注意
// 静的ファイルの配信設定
- // ※404ページを表示させることができないのでstモジュールの利用一時停止
- // app.use(st({
- // path: path.join(__dirname, 'public'),
- // url: '/'
- // }));
+ app.use(express.static(path.join(__dirname, 'public')));
// app.routerを設定すると、通信の実行までに必要なマッピング処理を省略できる
// ルーティングの機能を提供する。これはExpressでの拡張
- app.use(express.compress());
- app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);
- app.use(express.csrf()); // この位置じゃないと動かない?順番要注意
+ // エラー処理をハンドリングするミドルウェア
app.use(middleware.notFound);
app.use(middleware.unauthorized);
app.use(middleware.error);
@@ -240,7 +240,7 @@ function authenticated(req, res, next) {
//CSRF対策用トークンを設定
function csrf(req, res, next) {
- res.locals.token = req.session._csrf;
+ res.locals._csrf = req.session._csrf;
next();
}
View
4 lib/controllers/chatroom.js
@@ -119,7 +119,7 @@ exports.create = function(req, res, next) {
//CSRF Check
- if (_csrf !== req.param('token')) {
+ if (_csrf !== req.param('_csrf')) {
logger.error('CSRF Invalid');
return next(new Error());
}
@@ -292,7 +292,7 @@ exports.delete = function(req, res, next) {
var _csrf = req.session._csrf;
//CSRF Check
- if (_csrf !== req.param('token')) {
+ if (_csrf !== req.param('_csrf')) {
logger.error('CSRF Invalid');
return next(new Error());
}
View
2  lib/controllers/mypage.js
@@ -50,7 +50,7 @@ exports.deactivation = function(req, res, next) {
var _csrf = req.session._csrf;
//CSRF Check
- if (_csrf !== req.param('token')) {
+ if (_csrf !== req.param('_csrf')) {
logger.error('CSRF Invalid');
return next(new Error());
}
View
2  lib/controllers/socketIo.js
@@ -69,7 +69,7 @@ exports.onConnection = function(socket) {
if (!user) { return; }
//CSRF Check
- if (_csrf && _csrf !== data.token) {
+ if (_csrf && _csrf !== data._csrf) {
logger.error('CSRF Invalid');
return;
}
View
3  lib/controllers/user.js
@@ -21,9 +21,10 @@ exports.create = function(req, res, next) {
var isUpdate = req.param('isUpdate');
var _csrf = req.session._csrf;
+ logger.info('#####create');
//CSRF Check
- if (_csrf !== req.param('token')) {
+ if (_csrf !== req.param('_csrf')) {
logger.error('CSRF Invalid');
return next(new Error());
}
View
10 lib/middleware/index.js
@@ -3,7 +3,7 @@ var utils = require('../utils');
var config = require('config');
-//SSL通信を強制
+// SSL通信を強制するミドルウェア
exports.ssl = function(req, res, next) {
if (!req.secure) {
var host = config.server.host;
@@ -23,6 +23,7 @@ exports.ssl = function(req, res, next) {
};
+// セッションデータをejsからアクセスできるように設定
exports.sessionData = function(req, res, next) {
var logger = app.set('logger');
@@ -35,6 +36,8 @@ exports.sessionData = function(req, res, next) {
next();
};
+
+// 環境変数をejsからアクセスできるように設定
exports.envData = function(req, res, next) {
var logger = app.set('logger');
app.locals.env = app.settings.env;
@@ -42,12 +45,15 @@ exports.envData = function(req, res, next) {
next();
};
+
+// 設定ファイルをejsからアクセスできるように設定
exports.configData = function(req, res, next) {
var logger = app.set('logger');
app.locals.config = config;
next();
};
+//404 Not Foundをハンドリングするミドルウェア
exports.notFound = function(err, req, res, next) {
var logger = app.set('logger');
@@ -65,6 +71,7 @@ exports.notFound = function(err, req, res, next) {
}
};
+//401 Unauthorizedをハンドリングするミドルウェア
exports.unauthorized = function(err, req, res, next) {
var logger = app.set('logger');
@@ -82,6 +89,7 @@ exports.unauthorized = function(err, req, res, next) {
}
};
+//システムエラーなどその他のエラーをハンドリングするミドルウェア
exports.error = function(err, req, res, next) {
var logger = app.set('logger');
View
2  lib/utils/index.js
@@ -2,12 +2,14 @@ var app = require('../../app');
var util = require('util');
+//改行コードをbrタグに変換
exports.nl2br = function(str) {
if (str) {
return str.replace(/\n/g, '<br/>');
}
};
+//HTMLエスケープ処理
exports.escHtml = function(str) {
if (str) {
str = str.replace(/&/g, '&amp;');
View
4 lib/utils/mail.js
@@ -9,6 +9,7 @@ var Mail = function() {
};
+// 共通メール送信処理
Mail.prototype.send = function(params) {
var mailServer = app.set('mailServer');
var logger = app.set('logger');
@@ -30,6 +31,7 @@ Mail.prototype.send = function(params) {
});
};
+// 入会時のメール送信
Mail.prototype.sendWelcomeMail = function(userName, to) {
var template = __dirname+'/../../views/mail/welcome.ejs';
var subject = config.mail.subject.welcome;
@@ -46,6 +48,7 @@ Mail.prototype.sendWelcomeMail = function(userName, to) {
});
};
+// 退会時のメール送信
Mail.prototype.sendDeactivationMail = function(userName, to) {
var template = __dirname+'/../../views/mail/deactivation.ejs';
var subject = config.mail.subject.deactivation;
@@ -62,6 +65,7 @@ Mail.prototype.sendDeactivationMail = function(userName, to) {
});
};
+// プロフィール更新時のメール送信
Mail.prototype.sendProfileMail = function(userName, to) {
var template = __dirname+'/../../views/mail/profile.ejs';
var subject = config.mail.subject.profile;
View
6 public/js/dist/chatroom.js
@@ -101,7 +101,7 @@
initialize: function() {
this.collection = new syaberi.Chats;
this.uploadCancelFlg = 0;
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
var message = $.trim($('#message1').val());
@@ -122,7 +122,7 @@
message: message,
type: CHAT_COMMENT,
isUrlOpen: isUrlOpen,
- token: this.token
+ _csrf: this._csrf
});
this.clearInputUserMessage();
@@ -153,7 +153,7 @@
chatroomId: chatroomId,
chatId: chatId,
userId: userId,
- token: this.token
+ _csrf: this._csrf
});
}
},
View
2  public/js/dist/chatroom.min.js
@@ -1 +1 @@
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.chat={},e.templates.chat.chatL=Handlebars.compile('<div class="message-owner-inbox" id="chat-content-{{chatId}}"> <div class="owner-icon"> <a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a> </div> <div class="owner-titlebox"> <p class="owner-title">{{{message}}}</p> {{#if extImageUrl}} <img src="{{extImageUrl}}" class="owner-img"> {{/if}} {{#if youtubeVid}} <iframe width="500" height="300" src=" http://www.youtube.com/embed/{{youtubeVid}}" frameborder="0" allowfullscreen></iframe> {{/if}} <div class="owner-username"><a href="/users/{{userId}}">by.{{userName}}</a></div> <div class="owner-date">{{time}} [1] {{#if isHis}} <img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}"> {{/if}} </div> </div> </div>'),e.templates.chat.chatR=Handlebars.compile('<div class="message-member-inbox" id="chat-content-{{chatId}}"> <div class="member-icon"> <a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a> </div> <div class="member-titlebox"> <p class="member-title">{{{message}}}</p> {{#if extImageUrl}} <img src="{{extImageUrl}}" class="member-img"> {{/if}} {{#if youtubeVid}} <iframe width="500" height="300" src=" http://www.youtube.com/embed/{{youtubeVid}}" frameborder="0" allowfullscreen></iframe> {{/if}} <div class="member-username"><a href="/users/{{userId}}">by.{{userName}}</a></div> <div class="member-date">{{time}} [2] {{#if isHis}} <img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}"> {{/if}} </div> {{#if isInvite}}{{#unless isUrlOpen}}{{#if isOwner}} <a href="javascript:void(0);" class="start_chat" data-userid="{{userId}}" data-chatid="{{chatId}}">[招待]</a> {{/if}}{{/unless}}{{/if}} </div> </div>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chat=Backbone.Model.extend({id:null,userId:null,userName:null,type:null,body:null,image:null,time:null,url:"/chats"}),e.Chats=Backbone.Collection.extend({model:e.Chat,url:"/chats"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=1,n=2,r=3;e.ChatView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","keydown #message1":"keydown","click img.delete_cmt":"destroy","click a.start_chat":"invite","change #uploadings_input":"upload","change #message1":"uploadOff"},initialize:function(){this.collection=new e.Chats,this.uploadCancelFlg=0,this.token=$("#token").val()},submit:function(n){var r=$.trim($("#message1").val());if(r&&r!==""){var i=$("html").data("chatroom"),s=$("html").data("userid"),o=$("html").data("username"),u=$("html").data("userimage"),a=$("html").data("urlopen");return e.socket.emit("message",{mode:"create",chatroomId:i,userId:s,userName:o,userImage:u,message:r,type:t,isUrlOpen:a,token:this.token}),this.clearInputUserMessage(),!1}},keydown:function(e){if(e.shiftKey!==!0&&e.keyCode===13)return this.submit(e),!1},destroy:function(t){if(window.confirm("本当に削除しますか?")){var n=$(t.target),r=n.data("chatid"),i=$("html").data("chatroom"),s=$("html").data("userid");e.socket.emit("message",{mode:"destroy",chatroomId:i,chatId:r,userId:s,token:this.token})}},invite:function(e){var t=$(e.target),n=t.data("userid"),r=t.data("chatid"),i=$("html").data("chatroom");window.confirm("このユーザとチャットを開始しますか?")&&$.ajax({type:"POST",url:"/chatrooms/"+i+"/invite",data:"member="+n+"&chat="+r,success:function(e){location.href="/chatrooms/"+i+"/open"}})},upload:function(){$("#uploadings_input").upload("/upload",function(e){if(e){var t=e,n=t.split('": "'),r=n[1].split('"}</pre>'),i=$("input#uploadings_input").val().split("\\"),s;for(var o=0;o<i.length;o++)if(i[o].indexOf(".jpg")!=-1||i[o].indexOf(".jpeg")!=-1||i[o].indexOf(".JPG")!=-1||i[o].indexOf(".png")!=-1||i[o].indexOf(".PNG")!=-1||i[o].indexOf(".gif")!=-1||i[o].indexOf(".GIF")!=-1)s=i[o];$("#message1").val(s),this.uploadCancelFlg=1,$("#message1").attr("disabled","disabled"),$("#realUpfile").val(r[0])}},"html")},uploadOff:function(){$("#message1").removeAttr("disabled"),this.uploadCancelFlg===1&&($("input#uploadings_input").val(""),this.uploadCancelFlg=0)},appendMessage:function(t){var n,r=$("html").data("status"),i=$("html").data("urlopen"),s=$("html").data("userid"),o=$("html").data("ownerid"),u={chatId:t.chatId,userImage:t.userImage,userId:t.userId,userName:t.userName,time:t.time,message:t.message,isOwner:s===o,isHis:s===t.userId,isInvite:r!==2,isUrlOpen:i,extImageUrl:"",youtubeVid:""};if(e.util.isUrl(t.message)){var a=e.util.getUrl(t.message);if(e.util.isImageUrl(a))u.extImageUrl=a;else if(e.util.isYoutube(a)){var f=e.util.getYoutubeVid(a);f&&(u.youtubeVid=f)}}o===t.userId?n=e.templates.chat.chatL(u):n=e.templates.chat.chatR(u),$("#lines1").append(n),!i&&t.userId===s&&o!=s&&$("#section_thread_bottom").animate({height:"hide",opacity:"hide"},"slow")},destroyMessage:function(e){var t=e.chatId,n=$("html").data("userid"),r=$("html").data("ownerid");n&&r!=n&&e.userId===n&&$("#section_thread_bottom").animate({height:"show",opacity:"1.0"},"slow"),$("#chat-content-"+t).animate({height:"hide",opacity:"hide"},"slow",function(){$("#chat-content-"+t).remove()})},render:function(){},clearInputUserMessage:function(){$("#message1").val("").focus(),$("#html_image_preview").remove(),$("#user_up_img").remove(),$("#drop_message").show()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=$("html").data("host"),n=$("html").data("chatroom"),r=$("html").data("urlopen"),i,s=!1;r?i=t+"?id="+n+"&urlopen="+r:i=t+"?id="+n,e.socket=io.connect(i,{reconnect:!0,"reconnection delay":300,"max reconnection attempts":10}),e.socket.on("connect",function(){s=!0}),e.socket.on("disconnect",function(e){s=!1}),$(function(){var t=new e.ChatView;t.render(),Backbone.emulateHTTP=!0,e.socket.on("message",function(e){e.mode==="create"?t.appendMessage(e):e.mode==="destroy"&&t.destroyMessage(e)})})}.call(this);
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.chat={},e.templates.chat.chatL=Handlebars.compile('<div class="message-owner-inbox" id="chat-content-{{chatId}}"> <div class="owner-icon"> <a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a> </div> <div class="owner-titlebox"> <p class="owner-title">{{{message}}}</p> {{#if extImageUrl}} <img src="{{extImageUrl}}" class="owner-img"> {{/if}} {{#if youtubeVid}} <iframe width="500" height="300" src=" http://www.youtube.com/embed/{{youtubeVid}}" frameborder="0" allowfullscreen></iframe> {{/if}} <div class="owner-username"><a href="/users/{{userId}}">by.{{userName}}</a></div> <div class="owner-date">{{time}} [1] {{#if isHis}} <img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}"> {{/if}} </div> </div> </div>'),e.templates.chat.chatR=Handlebars.compile('<div class="message-member-inbox" id="chat-content-{{chatId}}"> <div class="member-icon"> <a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a> </div> <div class="member-titlebox"> <p class="member-title">{{{message}}}</p> {{#if extImageUrl}} <img src="{{extImageUrl}}" class="member-img"> {{/if}} {{#if youtubeVid}} <iframe width="500" height="300" src=" http://www.youtube.com/embed/{{youtubeVid}}" frameborder="0" allowfullscreen></iframe> {{/if}} <div class="member-username"><a href="/users/{{userId}}">by.{{userName}}</a></div> <div class="member-date">{{time}} [2] {{#if isHis}} <img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}"> {{/if}} </div> {{#if isInvite}}{{#unless isUrlOpen}}{{#if isOwner}} <a href="javascript:void(0);" class="start_chat" data-userid="{{userId}}" data-chatid="{{chatId}}">[招待]</a> {{/if}}{{/unless}}{{/if}} </div> </div>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chat=Backbone.Model.extend({id:null,userId:null,userName:null,type:null,body:null,image:null,time:null,url:"/chats"}),e.Chats=Backbone.Collection.extend({model:e.Chat,url:"/chats"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=1,n=2,r=3;e.ChatView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","keydown #message1":"keydown","click img.delete_cmt":"destroy","click a.start_chat":"invite","change #uploadings_input":"upload","change #message1":"uploadOff"},initialize:function(){this.collection=new e.Chats,this.uploadCancelFlg=0,this._csrf=$("#_csrf").val()},submit:function(n){var r=$.trim($("#message1").val());if(r&&r!==""){var i=$("html").data("chatroom"),s=$("html").data("userid"),o=$("html").data("username"),u=$("html").data("userimage"),a=$("html").data("urlopen");return e.socket.emit("message",{mode:"create",chatroomId:i,userId:s,userName:o,userImage:u,message:r,type:t,isUrlOpen:a,_csrf:this._csrf}),this.clearInputUserMessage(),!1}},keydown:function(e){if(e.shiftKey!==!0&&e.keyCode===13)return this.submit(e),!1},destroy:function(t){if(window.confirm("本当に削除しますか?")){var n=$(t.target),r=n.data("chatid"),i=$("html").data("chatroom"),s=$("html").data("userid");e.socket.emit("message",{mode:"destroy",chatroomId:i,chatId:r,userId:s,_csrf:this._csrf})}},invite:function(e){var t=$(e.target),n=t.data("userid"),r=t.data("chatid"),i=$("html").data("chatroom");window.confirm("このユーザとチャットを開始しますか?")&&$.ajax({type:"POST",url:"/chatrooms/"+i+"/invite",data:"member="+n+"&chat="+r,success:function(e){location.href="/chatrooms/"+i+"/open"}})},upload:function(){$("#uploadings_input").upload("/upload",function(e){if(e){var t=e,n=t.split('": "'),r=n[1].split('"}</pre>'),i=$("input#uploadings_input").val().split("\\"),s;for(var o=0;o<i.length;o++)if(i[o].indexOf(".jpg")!=-1||i[o].indexOf(".jpeg")!=-1||i[o].indexOf(".JPG")!=-1||i[o].indexOf(".png")!=-1||i[o].indexOf(".PNG")!=-1||i[o].indexOf(".gif")!=-1||i[o].indexOf(".GIF")!=-1)s=i[o];$("#message1").val(s),this.uploadCancelFlg=1,$("#message1").attr("disabled","disabled"),$("#realUpfile").val(r[0])}},"html")},uploadOff:function(){$("#message1").removeAttr("disabled"),this.uploadCancelFlg===1&&($("input#uploadings_input").val(""),this.uploadCancelFlg=0)},appendMessage:function(t){var n,r=$("html").data("status"),i=$("html").data("urlopen"),s=$("html").data("userid"),o=$("html").data("ownerid"),u={chatId:t.chatId,userImage:t.userImage,userId:t.userId,userName:t.userName,time:t.time,message:t.message,isOwner:s===o,isHis:s===t.userId,isInvite:r!==2,isUrlOpen:i,extImageUrl:"",youtubeVid:""};if(e.util.isUrl(t.message)){var a=e.util.getUrl(t.message);if(e.util.isImageUrl(a))u.extImageUrl=a;else if(e.util.isYoutube(a)){var f=e.util.getYoutubeVid(a);f&&(u.youtubeVid=f)}}o===t.userId?n=e.templates.chat.chatL(u):n=e.templates.chat.chatR(u),$("#lines1").append(n),!i&&t.userId===s&&o!=s&&$("#section_thread_bottom").animate({height:"hide",opacity:"hide"},"slow")},destroyMessage:function(e){var t=e.chatId,n=$("html").data("userid"),r=$("html").data("ownerid");n&&r!=n&&e.userId===n&&$("#section_thread_bottom").animate({height:"show",opacity:"1.0"},"slow"),$("#chat-content-"+t).animate({height:"hide",opacity:"hide"},"slow",function(){$("#chat-content-"+t).remove()})},render:function(){},clearInputUserMessage:function(){$("#message1").val("").focus(),$("#html_image_preview").remove(),$("#user_up_img").remove(),$("#drop_message").show()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=$("html").data("host"),n=$("html").data("chatroom"),r=$("html").data("urlopen"),i,s=!1;r?i=t+"?id="+n+"&urlopen="+r:i=t+"?id="+n,e.socket=io.connect(i,{reconnect:!0,"reconnection delay":300,"max reconnection attempts":10}),e.socket.on("connect",function(){s=!0}),e.socket.on("disconnect",function(e){s=!1}),$(function(){var t=new e.ChatView;t.render(),Backbone.emulateHTTP=!0,e.socket.on("message",function(e){e.mode==="create"?t.appendMessage(e):e.mode==="destroy"&&t.destroyMessage(e)})})}.call(this);
View
4 public/js/dist/createChatroom.js
@@ -56,7 +56,7 @@
initialize: function() {
this.model = new syaberi.Chatroom;
Backbone.Validation.bind(this);
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
event.preventDefault();
@@ -91,7 +91,7 @@
title: title,
description: description,
publicYN: publicYN,
- token: this.token
+ _csrf: this._csrf
}, {
success: function(model, res) {
var chatroomId = res.chatroomId;
View
2  public/js/dist/createChatroom.min.js
@@ -1 +1 @@
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.CreateChatroomView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","blur input.title":"setSearchText","focus input.title":"clearSearchText"},initialize:function(){this.model=new e.Chatroom,Backbone.Validation.bind(this),this.token=$("#token").val()},submit:function(e){e.preventDefault();var t=this;this._clearSearchText($("#title1")),this._clearSearchText($("#title2"));var n=$.trim($("#categoryId").val()),r=$.trim($("#title1").val()),i=$.trim($("#title2").val()),s=$.trim($("#description").val()),o=$("#publicYN").val();this.model.set({categoryId:n,title1:r,title2:i,description:s,publicYN:o});if(this.model.isValid()){var u=r+"けど、"+i+"について、話しませんか?";this.model.save({categoryId:n,title:u,description:s,publicYN:o,token:this.token},{success:function(e,t){var n=t.chatroomId;location.href="/chatrooms/"+n},error:function(e,t){alert(t.responseText)}})}this.model.bind("validated:invalid",function(e,n){for(key in n){var r=n[key];if(key==="title1"||key==="title2")key="title";$("#error_"+key).text(r)}t._setSearchText($("#title1")),t._setSearchText($("#title2"))})},clearSearchText:function(e){var t=$(e.target);this._clearSearchText(t)},_clearSearchText:function(e){e.val()===e.prop("defaultValue")&&e.css("color","#000").val("")},setSearchText:function(e){var t=$(e.target);this._setSearchText(t)},_setSearchText:function(e){$.trim(e.val())===""&&e.css("color","#999").val(e.prop("defaultValue"))},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.CreateChatroomView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.CreateChatroomView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","blur input.title":"setSearchText","focus input.title":"clearSearchText"},initialize:function(){this.model=new e.Chatroom,Backbone.Validation.bind(this),this._csrf=$("#_csrf").val()},submit:function(e){e.preventDefault();var t=this;this._clearSearchText($("#title1")),this._clearSearchText($("#title2"));var n=$.trim($("#categoryId").val()),r=$.trim($("#title1").val()),i=$.trim($("#title2").val()),s=$.trim($("#description").val()),o=$("#publicYN").val();this.model.set({categoryId:n,title1:r,title2:i,description:s,publicYN:o});if(this.model.isValid()){var u=r+"けど、"+i+"について、話しませんか?";this.model.save({categoryId:n,title:u,description:s,publicYN:o,_csrf:this._csrf},{success:function(e,t){var n=t.chatroomId;location.href="/chatrooms/"+n},error:function(e,t){alert(t.responseText)}})}this.model.bind("validated:invalid",function(e,n){for(key in n){var r=n[key];if(key==="title1"||key==="title2")key="title";$("#error_"+key).text(r)}t._setSearchText($("#title1")),t._setSearchText($("#title2"))})},clearSearchText:function(e){var t=$(e.target);this._clearSearchText(t)},_clearSearchText:function(e){e.val()===e.prop("defaultValue")&&e.css("color","#000").val("")},setSearchText:function(e){var t=$(e.target);this._setSearchText(t)},_setSearchText:function(e){$.trim(e.val())===""&&e.css("color","#999").val(e.prop("defaultValue"))},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.CreateChatroomView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
View
4 public/js/dist/deactivation.js
@@ -8,7 +8,7 @@
'click #cancel': 'cancel'
},
initialize: function() {
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
event.preventDefault();
@@ -17,7 +17,7 @@
$.ajax({
type: 'POST',
url: '/deactivation',
- data: 'token='+this.token,
+ data: '_csrf='+this._csrf,
success: function(data) {
location.href = '/';
}
View
2  public/js/dist/deactivation.min.js
@@ -1 +1 @@
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.DeactivationView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","click #cancel":"cancel"},initialize:function(){this.token=$("#token").val()},submit:function(e){e.preventDefault();var t=this;$.ajax({type:"POST",url:"/deactivation",data:"token="+this.token,success:function(e){location.href="/"}})},cancel:function(e){e.preventDefault(),location.href="/mypage"},render:function(){}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.DeactivationView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.DeactivationView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","click #cancel":"cancel"},initialize:function(){this._csrf=$("#_csrf").val()},submit:function(e){e.preventDefault();var t=this;$.ajax({type:"POST",url:"/deactivation",data:"_csrf="+this._csrf,success:function(e){location.href="/"}})},cancel:function(e){e.preventDefault(),location.href="/mypage"},render:function(){}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.DeactivationView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
View
4 public/js/dist/deleteChatroom.js
@@ -8,7 +8,7 @@
'click #cancel': 'cancel'
},
initialize: function() {
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
event.preventDefault();
@@ -18,7 +18,7 @@
$.ajax({
type: 'POST',
url: '/chatrooms/'+chatroomId+'/delete',
- data: 'token='+this.token,
+ data: '_csrf='+this._csrf,
success: function(data) {
location.href = '/';
}
View
2  public/js/dist/deleteChatroom.min.js
@@ -1 +1 @@
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.DeleteChatroomView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","click #cancel":"cancel"},initialize:function(){this.token=$("#token").val()},submit:function(e){e.preventDefault();var t=this,n=$("html").data("chatroom");$.ajax({type:"POST",url:"/chatrooms/"+n+"/delete",data:"token="+this.token,success:function(e){location.href="/"}})},cancel:function(e){e.preventDefault();var t=$("html").data("chatroom");location.href="/chatrooms/"+t+"/open"},render:function(){}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.DeleteChatroomView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.DeleteChatroomView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","click #cancel":"cancel"},initialize:function(){this._csrf=$("#_csrf").val()},submit:function(e){e.preventDefault();var t=this,n=$("html").data("chatroom");$.ajax({type:"POST",url:"/chatrooms/"+n+"/delete",data:"_csrf="+this._csrf,success:function(e){location.href="/"}})},cancel:function(e){e.preventDefault();var t=$("html").data("chatroom");location.href="/chatrooms/"+t+"/open"},render:function(){}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.DeleteChatroomView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
View
4 public/js/dist/mypage.js
@@ -169,7 +169,7 @@
this.model = new syaberi.User;
this.collection = new syaberi.Chatrooms;
this.mode = 'owner';
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
Backbone.Validation.bind(this);
},
getOwnerChatrooms: function(event) {
@@ -265,7 +265,7 @@
userName: userName,
email: email,
description: description,
- token: this.token
+ _csrf: this._csrf
}, {
success: function() {
location.href = '/mypage';
View
2  public/js/dist/mypage.min.js
@@ -1 +1 @@
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.mypage={},e.templates.mypage.list=Handlebars.compile('<div class="room"> <div class="room-inbox"> <div class="room-icon"> {{#if chatroom.isOwnerInactive}} <img class="icon_m" src="/img/chara.png"> {{else}} <a href="{{chatroom.ownerpage}}"><img class="icon_m" src="{{chatroom.ownerimage}}"></a> {{/if}} </div> <div class="room-titlebox"> <h2 class="room-title"><a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">{{chatroom.title}}</a></h2> <div class="cat-icon"><a href="#">{{chatroom.category}}</a></div> <div class="room-username"> {{#if chatroom.isOwnerInactive}} by.退会済み {{else}} <a href="{{chatroom.ownerpage}}">by.{{chatroom.owner}}</a> {{/if}} </div> </div> <div class="room-button"> <a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}"> <input type="button" class="button_yg" value="話す"> </a> </div> </div> </div>'),e.templates.mypage.profile=Handlebars.compile('<form method="" action="" style="padding-top:20px;"> <table> <tr> <th class="label">ニックネーム:<div class="necessity">※必須</div></th> <td class="data"> <input type="text" name="userName" id="userName" class="text-box" value="{{{userName}}}"> <div id="error_userName" class="error"></div> </td> </tr> <tr> <th class="label">メールアドレス:<div class="necessity">※必須</div></th> <td class="data"> <input type="text" name="email" id="email" class="text-box" value="{{{email}}}"> <div id="error_email" class="error"></div> </td> </tr> <tr> <th class="label">プロフィール:</th> <td class="data"> <textarea name="description" id="description" class="textarea-box">{{{description}}}</textarea> <div id="error_description" class="error"></div> </td> </tr> </table> <div class="submit"> <input type="button" class="button_g" id="submit_1" value="保存"> </div> <div class="deactivate" style="margin-left:330px;"> <a href="/confirm_deactivation">シャベリハウスを退会する</a> </div> </form>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.MyPageView=Backbone.View.extend({el:$("html"),events:{"click #owner-chatrooms":"getOwnerChatrooms","click #entry-chatrooms":"getEntryChatrooms","click #join-chatrooms":"getJoinChatrooms","click #edit-profile":"showProfile","click #submit_1":"editProfile","click #view-more-events":"getMore"},initialize:function(){this.model=new e.User,this.collection=new e.Chatrooms,this.mode="owner",this.token=$("#token").val(),Backbone.Validation.bind(this)},getOwnerChatrooms:function(e){this.init_list(),$("li","#owner-chatrooms").addClass("active"),this.mode="owner",this.getChatrooms()},getEntryChatrooms:function(e){this.init_list(),$("li","#entry-chatrooms").addClass("active"),this.mode="entry",this.getChatrooms()},getJoinChatrooms:function(e){this.init_list(),$("li","#join-chatrooms").addClass("active"),this.mode="join",this.getChatrooms()},getMore:function(e){var t=this.collection.nextPage;this.getChatrooms(t)},getChatrooms:function(t){var n=this;t=t||1;var r=$("html").data("profileid");$("#view-more-events").hide(),$("#view-more-loader").show(),this.collection.fetch({data:{profileId:r,mode:this.mode,page:t},success:function(t,r){var i=r.chatrooms;i&&$.each(r.chatrooms,function(t,r){var i=e.templates.mypage.list({host:$("html").data("host"),chatroom:r,isUrlOpen:n.mode==="entry"?!1:!0});$("#article_area").append(i)}),$("#view-more-loader").hide(),r.nextPage!==0&&$("#view-more-events").show()}})},showProfile:function(t){var n=$("html").data("profilename"),r=$("html").data("profileemail"),i=$("html").data("profiledescription");this.init_list(),$("#view-more-events").hide(),$("li","#edit-profile").addClass("active");var s=e.templates.mypage.profile({userName:n,email:r,description:i});$("#article_area").append(s)},editProfile:function(e){e.preventDefault();var t=$("html").data("profileid"),n=$.trim($("#userName").val()),r=$.trim($("#email").val()),i=$.trim($("#description").val());this.model.set({userId:t,userName:n,email:r,description:i,isUpdate:!0}),this.model.isValid()&&this.model.save({userId:t,userName:n,email:r,description:i,token:this.token},{success:function(){location.href="/mypage"},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})},render:function(){this.getOwnerChatrooms()},init_list:function(){return $("li","#owner-chatrooms").removeClass("active"),$("li","#join-chatrooms").removeClass("active"),$("li","#edit-profile").removeClass("active"),$("#article_area").empty()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.MyPageView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.mypage={},e.templates.mypage.list=Handlebars.compile('<div class="room"> <div class="room-inbox"> <div class="room-icon"> {{#if chatroom.isOwnerInactive}} <img class="icon_m" src="/img/chara.png"> {{else}} <a href="{{chatroom.ownerpage}}"><img class="icon_m" src="{{chatroom.ownerimage}}"></a> {{/if}} </div> <div class="room-titlebox"> <h2 class="room-title"><a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">{{chatroom.title}}</a></h2> <div class="cat-icon"><a href="#">{{chatroom.category}}</a></div> <div class="room-username"> {{#if chatroom.isOwnerInactive}} by.退会済み {{else}} <a href="{{chatroom.ownerpage}}">by.{{chatroom.owner}}</a> {{/if}} </div> </div> <div class="room-button"> <a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}"> <input type="button" class="button_yg" value="話す"> </a> </div> </div> </div>'),e.templates.mypage.profile=Handlebars.compile('<form method="" action="" style="padding-top:20px;"> <table> <tr> <th class="label">ニックネーム:<div class="necessity">※必須</div></th> <td class="data"> <input type="text" name="userName" id="userName" class="text-box" value="{{{userName}}}"> <div id="error_userName" class="error"></div> </td> </tr> <tr> <th class="label">メールアドレス:<div class="necessity">※必須</div></th> <td class="data"> <input type="text" name="email" id="email" class="text-box" value="{{{email}}}"> <div id="error_email" class="error"></div> </td> </tr> <tr> <th class="label">プロフィール:</th> <td class="data"> <textarea name="description" id="description" class="textarea-box">{{{description}}}</textarea> <div id="error_description" class="error"></div> </td> </tr> </table> <div class="submit"> <input type="button" class="button_g" id="submit_1" value="保存"> </div> <div class="deactivate" style="margin-left:330px;"> <a href="/confirm_deactivation">シャベリハウスを退会する</a> </div> </form>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.MyPageView=Backbone.View.extend({el:$("html"),events:{"click #owner-chatrooms":"getOwnerChatrooms","click #entry-chatrooms":"getEntryChatrooms","click #join-chatrooms":"getJoinChatrooms","click #edit-profile":"showProfile","click #submit_1":"editProfile","click #view-more-events":"getMore"},initialize:function(){this.model=new e.User,this.collection=new e.Chatrooms,this.mode="owner",this._csrf=$("#_csrf").val(),Backbone.Validation.bind(this)},getOwnerChatrooms:function(e){this.init_list(),$("li","#owner-chatrooms").addClass("active"),this.mode="owner",this.getChatrooms()},getEntryChatrooms:function(e){this.init_list(),$("li","#entry-chatrooms").addClass("active"),this.mode="entry",this.getChatrooms()},getJoinChatrooms:function(e){this.init_list(),$("li","#join-chatrooms").addClass("active"),this.mode="join",this.getChatrooms()},getMore:function(e){var t=this.collection.nextPage;this.getChatrooms(t)},getChatrooms:function(t){var n=this;t=t||1;var r=$("html").data("profileid");$("#view-more-events").hide(),$("#view-more-loader").show(),this.collection.fetch({data:{profileId:r,mode:this.mode,page:t},success:function(t,r){var i=r.chatrooms;i&&$.each(r.chatrooms,function(t,r){var i=e.templates.mypage.list({host:$("html").data("host"),chatroom:r,isUrlOpen:n.mode==="entry"?!1:!0});$("#article_area").append(i)}),$("#view-more-loader").hide(),r.nextPage!==0&&$("#view-more-events").show()}})},showProfile:function(t){var n=$("html").data("profilename"),r=$("html").data("profileemail"),i=$("html").data("profiledescription");this.init_list(),$("#view-more-events").hide(),$("li","#edit-profile").addClass("active");var s=e.templates.mypage.profile({userName:n,email:r,description:i});$("#article_area").append(s)},editProfile:function(e){e.preventDefault();var t=$("html").data("profileid"),n=$.trim($("#userName").val()),r=$.trim($("#email").val()),i=$.trim($("#description").val());this.model.set({userId:t,userName:n,email:r,description:i,isUpdate:!0}),this.model.isValid()&&this.model.save({userId:t,userName:n,email:r,description:i,_csrf:this._csrf},{success:function(){location.href="/mypage"},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})},render:function(){this.getOwnerChatrooms()},init_list:function(){return $("li","#owner-chatrooms").removeClass("active"),$("li","#join-chatrooms").removeClass("active"),$("li","#edit-profile").removeClass("active"),$("#article_area").empty()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.MyPageView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
View
4 public/js/dist/register.js
@@ -41,7 +41,7 @@
},
initialize: function() {
this.model = new syaberi.User;
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
Backbone.Validation.bind(this);
},
submit: function(event) {
@@ -66,7 +66,7 @@
userName: userName,
email: email,
description: description,
- token: this.token
+ _csrf: this._csrf
}, {
success: function() {
var returnUrl = $.cookie('returnUrl');
View
2  public/js/dist/register.min.js
@@ -1 +1 @@
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.RegisterView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit"},initialize:function(){this.model=new e.User,this.token=$("#token").val(),Backbone.Validation.bind(this)},submit:function(e){e.preventDefault();var t=$.trim($("#userName").val()),n=$.trim($("#email").val()),r=$.trim($("#description").val()),i=$("#terms_check").is(":checked");i?(this.model.set({userName:t,email:n,description:r}),this.model.isValid()&&this.model.save({userName:t,email:n,description:r,token:this.token},{success:function(){var e=$.cookie("returnUrl");location.href=e},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})):alert("利用規約に同意する必要があります")},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.RegisterView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.RegisterView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit"},initialize:function(){this.model=new e.User,this._csrf=$("#_csrf").val(),Backbone.Validation.bind(this)},submit:function(e){e.preventDefault();var t=$.trim($("#userName").val()),n=$.trim($("#email").val()),r=$.trim($("#description").val()),i=$("#terms_check").is(":checked");i?(this.model.set({userName:t,email:n,description:r}),this.model.isValid()&&this.model.save({userName:t,email:n,description:r,_csrf:this._csrf},{success:function(){var e=$.cookie("returnUrl");location.href=e},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})):alert("利用規約に同意する必要があります")},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.RegisterView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
View
6 public/js/views/chat.js
@@ -17,7 +17,7 @@
initialize: function() {
this.collection = new syaberi.Chats;
this.uploadCancelFlg = 0;
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
var message = $.trim($('#message1').val());
@@ -38,7 +38,7 @@
message: message,
type: CHAT_COMMENT,
isUrlOpen: isUrlOpen,
- token: this.token
+ _csrf: this._csrf
});
this.clearInputUserMessage();
@@ -69,7 +69,7 @@
chatroomId: chatroomId,
chatId: chatId,
userId: userId,
- token: this.token
+ _csrf: this._csrf
});
}
},
View
4 public/js/views/createChatroom.js
@@ -11,7 +11,7 @@
initialize: function() {
this.model = new syaberi.Chatroom;
Backbone.Validation.bind(this);
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
event.preventDefault();
@@ -46,7 +46,7 @@
title: title,
description: description,
publicYN: publicYN,
- token: this.token
+ _csrf: this._csrf
}, {
success: function(model, res) {
var chatroomId = res.chatroomId;
View
4 public/js/views/deactivation.js
@@ -8,7 +8,7 @@
'click #cancel': 'cancel'
},
initialize: function() {
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
event.preventDefault();
@@ -17,7 +17,7 @@
$.ajax({
type: 'POST',
url: '/deactivation',
- data: 'token='+this.token,
+ data: '_csrf='+this._csrf,
success: function(data) {
location.href = '/';
}
View
4 public/js/views/deleteChatroom.js
@@ -8,7 +8,7 @@
'click #cancel': 'cancel'
},
initialize: function() {
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
},
submit: function(event) {
event.preventDefault();
@@ -18,7 +18,7 @@
$.ajax({
type: 'POST',
url: '/chatrooms/'+chatroomId+'/delete',
- data: 'token='+this.token,
+ data: '_csrf='+this._csrf,
success: function(data) {
location.href = '/';
}
View
4 public/js/views/mypage.js
@@ -17,7 +17,7 @@
this.model = new syaberi.User;
this.collection = new syaberi.Chatrooms;
this.mode = 'owner';
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
Backbone.Validation.bind(this);
},
getOwnerChatrooms: function(event) {
@@ -113,7 +113,7 @@
userName: userName,
email: email,
description: description,
- token: this.token
+ _csrf: this._csrf
}, {
success: function() {
location.href = '/mypage';
View
4 public/js/views/register.js
@@ -8,7 +8,7 @@
},
initialize: function() {
this.model = new syaberi.User;
- this.token = $('#token').val(); //for CSRF
+ this._csrf = $('#_csrf').val(); //for CSRF
Backbone.Validation.bind(this);
},
submit: function(event) {
@@ -33,7 +33,7 @@
userName: userName,
email: email,
description: description,
- token: this.token
+ _csrf: this._csrf
}, {
success: function() {
var returnUrl = $.cookie('returnUrl');
View
2  views/chatroom.ejs
@@ -317,6 +317,6 @@
<% include footer %>
</div>
-<input type="hidden" name="token" id="token" value="<%= token %>">
+<input type="hidden" name="_csrf" id="_csrf" value="<%= _csrf %>">
</body>
</html>
View
4 views/createChatroom.ejs
@@ -36,7 +36,7 @@
<div id="content">
<div class="left-content">
-
+
<form id="full-form-tag" name="full-form-tag" method="post" enctype="multipart/form-data">
<table>
<caption>(っ´∀`)っ)) 新しい部屋をつくる</caption>
@@ -86,6 +86,6 @@
</div><!-- content -->
<% include footer %>
-<input type="hidden" name="token" id="token" value="<%= token %>">
+<input type="hidden" name="_csrf" id="_csrf" value="<%= _csrf %>">
</body>
</html>
View
2  views/deactivation.ejs
@@ -48,6 +48,6 @@
</div><!-- content -->
<% include footer %>
-<input type="hidden" name="token" id="token" value="<%= token %>">
+<input type="hidden" name="_csrf" id="_csrf" value="<%= _csrf %>">
</body>
</html>
View
2  views/deleteChatroom.ejs
@@ -77,6 +77,6 @@
</div><!-- content -->
<% include footer %>
-<input type="hidden" name="token" id="token" value="<%= token %>">
+<input type="hidden" name="_csrf" id="_csrf" value="<%= _csrf %>">
</body>
</html>
View
2  views/mypage.ejs
@@ -146,6 +146,6 @@
<% include footer %>
</div>
-<input type="hidden" name="token" id="token" value="<%= token %>">
+<input type="hidden" name="_csrf" id="_csrf" value="<%= _csrf %>">
</body>
</html>
View
2  views/register.ejs
@@ -80,6 +80,6 @@
</div><!-- content -->
<% include footer %>
-<input type="hidden" name="token" id="token" value="<%= token %>">
+<input type="hidden" name="_csrf" id="_csrf" value="<%= _csrf %>">
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.