|
@@ -20,7 +20,7 @@ module.exports = function(crowi, app) {
|
|
|
//var storagePlugin = new pluginService('storage');
|
|
//var storagePlugin = new pluginService('storage');
|
|
|
//var storage = require('../service/storage').StorageService(config);
|
|
//var storage = require('../service/storage').StorageService(config);
|
|
|
|
|
|
|
|
- var tmpFile = req.files.userPicture || null;
|
|
|
|
|
|
|
+ var tmpFile = req.file || null;
|
|
|
if (!tmpFile) {
|
|
if (!tmpFile) {
|
|
|
return res.json({
|
|
return res.json({
|
|
|
'status': false,
|
|
'status': false,
|
|
@@ -29,7 +29,7 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var tmpPath = tmpFile.path;
|
|
var tmpPath = tmpFile.path;
|
|
|
- var filePath = User.createUserPictureFilePath(req.user, tmpFile.name);
|
|
|
|
|
|
|
+ var filePath = User.createUserPictureFilePath(req.user, tmpFile.filename + tmpFile.originalname);
|
|
|
var acceptableFileType = /image\/.+/;
|
|
var acceptableFileType = /image\/.+/;
|
|
|
|
|
|
|
|
if (!tmpFile.mimetype.match(acceptableFileType)) {
|
|
if (!tmpFile.mimetype.match(acceptableFileType)) {
|
|
@@ -82,13 +82,14 @@ module.exports = function(crowi, app) {
|
|
|
if (req.method == 'POST' && req.form.isValid) {
|
|
if (req.method == 'POST' && req.form.isValid) {
|
|
|
var name = userForm.name;
|
|
var name = userForm.name;
|
|
|
var email = userForm.email;
|
|
var email = userForm.email;
|
|
|
|
|
+ var lang= userForm.lang;
|
|
|
|
|
|
|
|
if (!User.isEmailValid(email)) {
|
|
if (!User.isEmailValid(email)) {
|
|
|
- req.form.errors.push('このメールアドレスは登録できません。(ホワイトリストなどを確認してください)');
|
|
|
|
|
|
|
+ req.form.errors.push('You can\'t update to that email address');
|
|
|
return res.render('me/index', {});
|
|
return res.render('me/index', {});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- userData.update(name, email, function(err, userData) {
|
|
|
|
|
|
|
+ userData.update(name, email, lang, function(err, userData) {
|
|
|
if (err) {
|
|
if (err) {
|
|
|
for (var e in err.errors) {
|
|
for (var e in err.errors) {
|
|
|
if (err.errors.hasOwnProperty(e)) {
|
|
if (err.errors.hasOwnProperty(e)) {
|
|
@@ -98,7 +99,8 @@ module.exports = function(crowi, app) {
|
|
|
return res.render('me/index', {});
|
|
return res.render('me/index', {});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- req.flash('successMessage', '更新しました');
|
|
|
|
|
|
|
+ req.i18n.changeLanguage(lang);
|
|
|
|
|
+ req.flash('successMessage', req.t('Updated'));
|
|
|
return res.redirect('/me');
|
|
return res.redirect('/me');
|
|
|
});
|
|
});
|
|
|
} else { // method GET
|
|
} else { // method GET
|
|
@@ -128,14 +130,14 @@ module.exports = function(crowi, app) {
|
|
|
var oldPassword = passwordForm.oldPassword;
|
|
var oldPassword = passwordForm.oldPassword;
|
|
|
|
|
|
|
|
if (userData.isPasswordSet() && !userData.isPasswordValid(oldPassword)) {
|
|
if (userData.isPasswordSet() && !userData.isPasswordValid(oldPassword)) {
|
|
|
- req.form.errors.push('現在のパスワードが違います。');
|
|
|
|
|
|
|
+ req.form.errors.push('Wrong current password');
|
|
|
return res.render('me/password', {
|
|
return res.render('me/password', {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// check password confirm
|
|
// check password confirm
|
|
|
if (newPassword != newPasswordConfirm) {
|
|
if (newPassword != newPasswordConfirm) {
|
|
|
- req.form.errors.push('確認用パスワードが一致しません');
|
|
|
|
|
|
|
+ req.form.errors.push('Failed to verify passwords');
|
|
|
} else {
|
|
} else {
|
|
|
userData.updatePassword(newPassword, function(err, userData) {
|
|
userData.updatePassword(newPassword, function(err, userData) {
|
|
|
if (err) {
|
|
if (err) {
|
|
@@ -147,7 +149,7 @@ module.exports = function(crowi, app) {
|
|
|
return res.render('me/password', {});
|
|
return res.render('me/password', {});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- req.flash('successMessage', 'パスワードを変更しました');
|
|
|
|
|
|
|
+ req.flash('successMessage', 'Password updated');
|
|
|
return res.redirect('/me/password');
|
|
return res.redirect('/me/password');
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -164,12 +166,12 @@ module.exports = function(crowi, app) {
|
|
|
if (req.method == 'POST' && req.form.isValid) {
|
|
if (req.method == 'POST' && req.form.isValid) {
|
|
|
userData.updateApiToken()
|
|
userData.updateApiToken()
|
|
|
.then(function(userData) {
|
|
.then(function(userData) {
|
|
|
- req.flash('successMessage', 'API Token を更新しました');
|
|
|
|
|
|
|
+ req.flash('successMessage', 'API Token updated');
|
|
|
return res.redirect('/me/apiToken');
|
|
return res.redirect('/me/apiToken');
|
|
|
})
|
|
})
|
|
|
.catch(function(err) {
|
|
.catch(function(err) {
|
|
|
//req.flash('successMessage',);
|
|
//req.flash('successMessage',);
|
|
|
- req.form.errors.push('API Token の更新に失敗しました');
|
|
|
|
|
|
|
+ req.form.errors.push('Failed to update API Token');
|
|
|
return res.render('me/api_token', {
|
|
return res.render('me/api_token', {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
@@ -187,7 +189,7 @@ module.exports = function(crowi, app) {
|
|
|
actions.deletePicture = function(req, res) {
|
|
actions.deletePicture = function(req, res) {
|
|
|
// TODO: S3 からの削除
|
|
// TODO: S3 からの削除
|
|
|
req.user.deleteImage(function(err, data) {
|
|
req.user.deleteImage(function(err, data) {
|
|
|
- req.flash('successMessage', 'プロフィール画像を削除しました');
|
|
|
|
|
|
|
+ req.flash('successMessage', 'Deleted profile picture');
|
|
|
res.redirect('/me');
|
|
res.redirect('/me');
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
@@ -201,7 +203,7 @@ module.exports = function(crowi, app) {
|
|
|
var toConnect = req.body.connectGoogle ? true : false;
|
|
var toConnect = req.body.connectGoogle ? true : false;
|
|
|
if (toDisconnect) {
|
|
if (toDisconnect) {
|
|
|
userData.deleteGoogleId(function(err, userData) {
|
|
userData.deleteGoogleId(function(err, userData) {
|
|
|
- req.flash('successMessage', 'Googleコネクトを解除しました。');
|
|
|
|
|
|
|
+ req.flash('successMessage', 'Disconnected from Google account');
|
|
|
|
|
|
|
|
return res.redirect('/me');
|
|
return res.redirect('/me');
|
|
|
});
|
|
});
|
|
@@ -232,13 +234,13 @@ module.exports = function(crowi, app) {
|
|
|
var googleId = tokenInfo.user_id;
|
|
var googleId = tokenInfo.user_id;
|
|
|
var googleEmail = tokenInfo.email;
|
|
var googleEmail = tokenInfo.email;
|
|
|
if (!User.isEmailValid(googleEmail)) {
|
|
if (!User.isEmailValid(googleEmail)) {
|
|
|
- req.flash('warningMessage.auth.google', 'このメールアドレスのGoogleアカウントはコネクトできません。');
|
|
|
|
|
|
|
+ req.flash('warningMessage.auth.google', 'You can\'t connect with this Google\'s account');
|
|
|
return res.redirect('/me');
|
|
return res.redirect('/me');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
User.findUserByGoogleId(googleId, function(err, googleUser) {
|
|
User.findUserByGoogleId(googleId, function(err, googleUser) {
|
|
|
if (!err && googleUser) {
|
|
if (!err && googleUser) {
|
|
|
- req.flash('warningMessage.auth.google', 'このGoogleアカウントは他のユーザーがコネクト済みです。');
|
|
|
|
|
|
|
+ req.flash('warningMessage.auth.google', 'This Google\'s account is connected by another user');
|
|
|
return res.redirect('/me');
|
|
return res.redirect('/me');
|
|
|
} else {
|
|
} else {
|
|
|
userData.updateGoogleId(googleId, function(err, userData) {
|
|
userData.updateGoogleId(googleId, function(err, userData) {
|
|
@@ -249,7 +251,7 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// TODO if err
|
|
// TODO if err
|
|
|
- req.flash('successMessage', 'Googleコネクトを設定しました。');
|
|
|
|
|
|
|
+ req.flash('successMessage', 'Connected with Google');
|
|
|
return res.redirect('/me');
|
|
return res.redirect('/me');
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|