Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into develop

# By Diego Sampaio (8) and Rodrigo Nascimento (2)
# Via Gabriel Engel (3) and Rodrigo Nascimento (2)
* 'develop' of github.com:RocketChat/Rocket.Chat:
  Increase the delay to render color fields
  fix guest users default role
  standardize colors definition
  improved clean button color
  support named color for message attachments
  added request debug messages
  trim integration messages
  Try to parse all request bodies as JSON
  new password reset screen
  fix reset password - closes #1502
pull/1783/head
Gabriel Engel 10 years ago
commit bab2ab3dba
  1. 3
      i18n/en.i18n.json
  2. 23
      packages/rocketchat-cors/cors.coffee
  3. 4
      packages/rocketchat-integrations/server/api/api.coffee
  4. 3
      packages/rocketchat-lib/package.js
  5. 10
      packages/rocketchat-lib/server/lib/debug.js
  6. 2
      packages/rocketchat-livechat/server/methods/registerGuest.js
  7. 7
      packages/rocketchat-message-attachments/client/messageAttachment.coffee
  8. 38
      packages/rocketchat-theme/server/variables.coffee
  9. 4
      packages/rocketchat-ui-admin/admin/admin.coffee
  10. 2
      packages/rocketchat-ui-login/login/layout.html
  11. 9
      packages/rocketchat-ui-login/package.js
  12. 15
      packages/rocketchat-ui-login/reset-password/resetPassword.html
  13. 26
      packages/rocketchat-ui-login/reset-password/resetPassword.js
  14. 6
      packages/rocketchat-ui-login/routes.js
  15. 2
      packages/rocketchat-ui-master/master/main.html
  16. 21
      packages/rocketchat-ui/lib/accounts.coffee
  17. 1
      packages/rocketchat-ui/package.js
  18. 4
      server/lib/accounts.coffee

@ -340,6 +340,7 @@
"Password_changed_successfully" : "Password changed successfully", "Password_changed_successfully" : "Password changed successfully",
"People" : "People", "People" : "People",
"Please_enter_value_for_url" : "Please enter a value for the url of your avatar.", "Please_enter_value_for_url" : "Please enter a value for the url of your avatar.",
"Please_enter_your_new_password_below" : "Please enter your new password below:",
"Please_wait" : "Please wait", "Please_wait" : "Please wait",
"Please_wait_activation" : "Please wait, this can take some time.", "Please_wait_activation" : "Please wait, this can take some time.",
"Please_wait_statistics" : "Please wait, statistics are being generated.", "Please_wait_statistics" : "Please wait, statistics are being generated.",
@ -383,6 +384,7 @@
"Remove_Admin" : "Remove Admin", "Remove_Admin" : "Remove Admin",
"Remove_custom_oauth" : "Remove custom oauth", "Remove_custom_oauth" : "Remove custom oauth",
"Remove_from_room" : "Remove from room", "Remove_from_room" : "Remove from room",
"Reset" : "Reset",
"Reset_password" : "Reset password", "Reset_password" : "Reset password",
"Restart" : "Restart", "Restart" : "Restart",
"Restart_the_server" : "Restart the server", "Restart_the_server" : "Restart the server",
@ -484,6 +486,7 @@
"There_is_no_integrations" : "There is no integrations", "There_is_no_integrations" : "There is no integrations",
"This_is_a_push_test_messsage" : "This is a push test messsage", "This_is_a_push_test_messsage" : "This is a push test messsage",
"True" : "True", "True" : "True",
"Type_your_new_password" : "Type your new password",
"Unarchive" : "Unarchive", "Unarchive" : "Unarchive",
"Unmute_user" : "Unmute user", "Unmute_user" : "Unmute user",
"Unnamed" : "Unnamed", "Unnamed" : "Unnamed",

@ -1,5 +1,28 @@
# Adding CORS headers so we can use CDNs for static content # Adding CORS headers so we can use CDNs for static content
# Try to parse all request bodies as JSON
WebApp.rawConnectHandlers.use (req, res, next) ->
if req._body
return next()
if req.headers['transfer-encoding'] is undefined and isNaN(req.headers['content-length'])
return next()
buf = ''
req.setEncoding('utf8')
req.on 'data', (chunk) -> buf += chunk
req.on 'end', ->
if RocketChat?.debugLevel? and RocketChat.debugLevel is 'debug'
console.log '[request]'.green, req.method, req.url, '\nheaders ->', req.headers, '\nbody ->', buf
try
req.body = JSON.parse(buf)
catch err
req.body = buf
next()
WebApp.rawConnectHandlers.use (req, res, next) -> WebApp.rawConnectHandlers.use (req, res, next) ->
res.setHeader("Access-Control-Allow-Origin", "*") res.setHeader("Access-Control-Allow-Origin", "*")
res.setHeader("X-Rocket-Chat-Version", VERSION) res.setHeader("X-Rocket-Chat-Version", VERSION)

@ -73,7 +73,7 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true,
message = message =
alias: @bodyParams.username or @bodyParams.alias or integration.alias alias: @bodyParams.username or @bodyParams.alias or integration.alias
msg: @bodyParams.text or @bodyParams.msg or '' msg: _.trim(@bodyParams.text or @bodyParams.msg or '')
attachments: @bodyParams.attachments attachments: @bodyParams.attachments
parseUrls: false parseUrls: false
bot: bot:
@ -92,7 +92,7 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true,
if _.isArray message.attachments if _.isArray message.attachments
for attachment in message.attachments for attachment in message.attachments
if attachment.msg if attachment.msg
attachment.text = attachment.msg attachment.text = _.trim(attachment.msg)
delete attachment.msg delete attachment.msg
RocketChat.sendMessage user, message, room, {} RocketChat.sendMessage user, message, room, {}

@ -25,11 +25,12 @@ Package.onUse(function(api) {
api.use('rocketchat:version'); api.use('rocketchat:version');
api.use('kadira:flow-router', 'client'); api.use('kadira:flow-router', 'client');
api.addFiles('lib/core.coffee');
// DEBUGGER // DEBUGGER
api.addFiles('server/lib/debug.js', 'server'); api.addFiles('server/lib/debug.js', 'server');
// COMMON LIB // COMMON LIB
api.addFiles('lib/core.coffee');
api.addFiles('lib/settings.coffee'); api.addFiles('lib/settings.coffee');
api.addFiles('lib/callbacks.coffee'); api.addFiles('lib/callbacks.coffee');
api.addFiles('lib/slashCommand.coffee'); api.addFiles('lib/slashCommand.coffee');

@ -1,21 +1,21 @@
var debugLevel = 'debug'; RocketChat.debugLevel = 'debug';
Meteor.startup(function() { Meteor.startup(function() {
RocketChat.settings.onload('Debug_Level', function(key, value, initialLoad) { RocketChat.settings.onload('Debug_Level', function(key, value, initialLoad) {
if (value) { if (value) {
debugLevel = value; RocketChat.debugLevel = value;
} }
}); });
var value = RocketChat.settings.get('Debug_Level'); var value = RocketChat.settings.get('Debug_Level');
if (value) { if (value) {
debugLevel = value; RocketChat.debugLevel = value;
} }
}); });
var wrapMethods = function(name, originalHandler, methodsMap) { var wrapMethods = function(name, originalHandler, methodsMap) {
methodsMap[name] = function() { methodsMap[name] = function() {
if (debugLevel === 'debug') { if (RocketChat.debugLevel === 'debug') {
console.log('[methods]'.green, name, '-> userId:', Meteor.userId(), ', arguments: ', arguments); console.log('[methods]'.green, name, '-> userId:', Meteor.userId(), ', arguments: ', arguments);
} }
@ -36,7 +36,7 @@ var originalMeteorPublish = Meteor.publish;
Meteor.publish = function(name, func) { Meteor.publish = function(name, func) {
return originalMeteorPublish(name, function() { return originalMeteorPublish(name, function() {
if (debugLevel === 'debug') { if (RocketChat.debugLevel === 'debug') {
console.log('[publish]'.green, name, '-> userId:', this.userId, ', arguments: ', arguments); console.log('[publish]'.green, name, '-> userId:', this.userId, ', arguments: ', arguments);
} }

@ -35,7 +35,7 @@ Meteor.methods({
} }
userData = { userData = {
username: user, username: user,
globalRoles: 'livechat-guest', globalRoles: ['livechat-guest'],
department: department department: department
}; };
userId = Accounts.insertUserDoc({}, userData); userId = Accounts.insertUserDoc({}, userData);

@ -21,3 +21,10 @@ Template.messageAttachment.helpers
getImageHeight: (height) -> getImageHeight: (height) ->
return height or 200 return height or 200
color: ->
switch @color
when 'good' then return '#35AC19'
when 'warning' then return '#FCB316'
when 'danger' then return '#D30230'
else return @color

@ -1,30 +1,30 @@
RocketChat.theme.addPublicColor "primary-background-color", "#04436A" RocketChat.theme.addPublicColor "primary-background-color", "#04436a"
RocketChat.theme.addPublicColor "primary-font-color", "#444444" RocketChat.theme.addPublicColor "primary-font-color", "#444444"
RocketChat.theme.addPublicColor "secondary-background-color", "#F4F4F4" RocketChat.theme.addPublicColor "secondary-background-color", "#f4f4f4"
RocketChat.theme.addPublicColor "secondary-font-color", "#7F7F7F" RocketChat.theme.addPublicColor "secondary-font-color", "#7f7f7f"
RocketChat.theme.addPublicColor "tertiary-background-color", "#EAEAEA" RocketChat.theme.addPublicColor "tertiary-background-color", "#eaeaea"
RocketChat.theme.addPublicColor "tertiary-font-color", "rgba(255, 255, 255, 0.6)" RocketChat.theme.addPublicColor "tertiary-font-color", "rgba(255, 255, 255, 0.6)"
RocketChat.theme.addPublicColor "quaternary-font-color", "#FFF" RocketChat.theme.addPublicColor "quaternary-font-color", "#ffffff"
RocketChat.theme.addPublicColor "action-buttons-color", "#13679a" RocketChat.theme.addPublicColor "action-buttons-color", "#13679a"
RocketChat.theme.addPublicColor "active-channel-background-color", "rgba(255, 255, 255, 0.075)" RocketChat.theme.addPublicColor "active-channel-background-color", "rgba(255, 255, 255, 0.075)"
RocketChat.theme.addPublicColor "active-channel-font-color", "rgba(255, 255, 255, 0.75)" RocketChat.theme.addPublicColor "active-channel-font-color", "rgba(255, 255, 255, 0.75)"
RocketChat.theme.addPublicColor "blockquote-background", "#CCC" RocketChat.theme.addPublicColor "blockquote-background", "#cccccc"
RocketChat.theme.addPublicColor "clean-buttons-color", "rgba(0, 0, 0, 0.025)" RocketChat.theme.addPublicColor "clean-buttons-color", "rgba(0, 0, 0, 0.25)"
RocketChat.theme.addPublicColor "code-background", "#F8F8F8" RocketChat.theme.addPublicColor "code-background", "#f8f8f8"
RocketChat.theme.addPublicColor "code-border", "#CCC" RocketChat.theme.addPublicColor "code-border", "#cccccc"
RocketChat.theme.addPublicColor "code-color", "#333" RocketChat.theme.addPublicColor "code-color", "#333333"
RocketChat.theme.addPublicColor "content-background-color", "#FFF" RocketChat.theme.addPublicColor "content-background-color", "#ffffff"
RocketChat.theme.addPublicColor "custom-scrollbar-color", "rgba(255, 255, 255, 0.05)" RocketChat.theme.addPublicColor "custom-scrollbar-color", "rgba(255, 255, 255, 0.05)"
RocketChat.theme.addPublicColor "info-active-font-color", "#FF0000" RocketChat.theme.addPublicColor "info-active-font-color", "#ff0000"
RocketChat.theme.addPublicColor "info-font-color", "#AAAAAA" RocketChat.theme.addPublicColor "info-font-color", "#aaaaaa"
RocketChat.theme.addPublicColor "input-font-color", "rgba(255, 255, 255, 0.85)" RocketChat.theme.addPublicColor "input-font-color", "rgba(255, 255, 255, 0.85)"
RocketChat.theme.addPublicColor "link-font-color", "#008CE3" RocketChat.theme.addPublicColor "link-font-color", "#008ce3"
RocketChat.theme.addPublicColor "message-hover-background-color", "#f9f9f9" RocketChat.theme.addPublicColor "message-hover-background-color", "#f9f9f9"
RocketChat.theme.addPublicColor "smallprint-font-color", "#C2E7FF" RocketChat.theme.addPublicColor "smallprint-font-color", "#c2e7ff"
RocketChat.theme.addPublicColor "smallprint-hover-color", "#FFFFFF" RocketChat.theme.addPublicColor "smallprint-hover-color", "#ffffff"
RocketChat.theme.addPublicColor "status-away", "#FCB316" RocketChat.theme.addPublicColor "status-away", "#fcb316"
RocketChat.theme.addPublicColor "status-busy", "#D30230" RocketChat.theme.addPublicColor "status-busy", "#d30230"
RocketChat.theme.addPublicColor "status-offline", "rgba(150, 150, 150, 0.50)" RocketChat.theme.addPublicColor "status-offline", "rgba(150, 150, 150, 0.50)"
RocketChat.theme.addPublicColor "status-online", "#35AC19" RocketChat.theme.addPublicColor "status-online", "#35ac19"
RocketChat.theme.addPublicColor "unread-notification-color", "#1dce73" RocketChat.theme.addPublicColor "unread-notification-color", "#1dce73"

@ -224,10 +224,10 @@ Template.admin.onRendered ->
Meteor.setTimeout -> Meteor.setTimeout ->
$('input.minicolors').minicolors({theme: 'rocketchat'}) $('input.minicolors').minicolors({theme: 'rocketchat'})
, 500 , 1000
Tracker.autorun -> Tracker.autorun ->
FlowRouter.watchPathChange() FlowRouter.watchPathChange()
Meteor.setTimeout -> Meteor.setTimeout ->
$('input.minicolors').minicolors({theme: 'rocketchat'}) $('input.minicolors').minicolors({theme: 'rocketchat'})
, 200 , 400

@ -2,7 +2,7 @@
<section class="full-page"> <section class="full-page">
<div class="wrapper"> <div class="wrapper">
{{ > loginHeader }} {{ > loginHeader }}
{{ > loginForm }} {{> Template.dynamic template=center}}
{{ > loginFooter }} {{ > loginFooter }}
</div> </div>
</section> </section>

@ -20,6 +20,13 @@ Package.onUse(function(api) {
'rocketchat:lib@0.0.1' 'rocketchat:lib@0.0.1'
]); ]);
api.use('kadira:flow-router', 'client');
api.addFiles('routes.js', 'client');
api.addFiles('reset-password/resetPassword.html', 'client');
api.addFiles('reset-password/resetPassword.js', 'client');
api.addFiles('login/footer.html', 'client'); api.addFiles('login/footer.html', 'client');
api.addFiles('login/form.html', 'client'); api.addFiles('login/form.html', 'client');
api.addFiles('login/header.html', 'client'); api.addFiles('login/header.html', 'client');
@ -37,4 +44,4 @@ Package.onUse(function(api) {
api.addFiles('login/services.coffee', 'client'); api.addFiles('login/services.coffee', 'client');
api.addFiles('login/social.coffee', 'client'); api.addFiles('login/social.coffee', 'client');
api.addFiles('username/username.coffee', 'client'); api.addFiles('username/username.coffee', 'client');
}); });

@ -0,0 +1,15 @@
<template name="resetPassword">
<form id="login-card" action="/">
<div class="fields">
<header>
<p>{{_ "Please_enter_your_new_password_below"}}</p>
</header>
<div class="input-text active">
<input type="password" name="newPassword" placeholder="{{_ "Type_your_new_password"}}" dir="auto" />
</div>
<div class="submit">
<button data-loading-text="{{_ "Please_wait"}}..." class="button primary resetpass"><span>{{_ "Reset"}}</span></button>
</div>
</div>
</form>
</template>

@ -0,0 +1,26 @@
Template.resetPassword.events({
'submit #login-card': function(event, instance) {
event.preventDefault();
var button = instance.$('button.resetpass');
RocketChat.Button.loading(button);
Accounts.resetPassword(FlowRouter.getParam('token'), instance.find('[name=newPassword]').value, function(error) {
RocketChat.Button.reset(button);
if (error) {
console.log(error);
swal({
title: t('Error_changing_password'),
type: 'error'
});
} else {
FlowRouter.go('home');
toastr.success(t('Password_changed_successfully'));
}
});
}
});
Template.resetPassword.onRendered(function() {
this.find('[name=newPassword]').focus();
});

@ -0,0 +1,6 @@
FlowRouter.route('/reset-password/:token', {
name: 'resetPassword',
action: function() {
BlazeLayout.render('loginLayout', {center: 'resetPassword'});
}
});

@ -43,7 +43,7 @@
<template name="main"> <template name="main">
{{#if subsReady}} {{#if subsReady}}
{{#unless logged}} {{#unless logged}}
{{> loginLayout}} {{> loginLayout center="loginForm"}}
{{else}} {{else}}
{{#unless hasUsername}} {{#unless hasUsername}}
{{> username}} {{> username}}

@ -1,17 +1,6 @@
Meteor.startup -> Accounts.onEmailVerificationLink (token, done) ->
Accounts.onEmailVerificationLink (token, done) -> Accounts.verifyEmail token, (error) ->
Accounts.verifyEmail token, (error) -> if not error?
if not error? alert(t('Email_verified'))
alert(t('Email_verified'))
done() done()
Accounts.onResetPasswordLink (token, done) ->
newPassword = prompt(t('New_password'))
Accounts.resetPassword token, newPassword, (error) ->
if error?
console.log error
alert(t('Error_changing_password'))
else
alert('Password_changed')
done()

@ -14,6 +14,7 @@ Package.onUse(function(api) {
api.versionsFrom('1.2.1'); api.versionsFrom('1.2.1');
api.use([ api.use([
'accounts-base',
'mongo', 'mongo',
'session', 'session',
'jquery', 'jquery',

@ -24,8 +24,8 @@ Accounts.emailTemplates.verifyEmail.text = (user, url) ->
resetPasswordText = Accounts.emailTemplates.resetPassword.text resetPasswordText = Accounts.emailTemplates.resetPassword.text
Accounts.emailTemplates.resetPassword.text = (user, url) -> Accounts.emailTemplates.resetPassword.text = (user, url) ->
url = url.replace Meteor.absoluteUrl(), Meteor.absoluteUrl() + 'login/' url = url.replace /\/#\//, '/'
verifyEmailText user, url resetPasswordText user, url
if RocketChat.settings.get 'Accounts_Enrollment_Email' if RocketChat.settings.get 'Accounts_Enrollment_Email'
Accounts.emailTemplates.enrollAccount.text = (user, url) -> Accounts.emailTemplates.enrollAccount.text = (user, url) ->

Loading…
Cancel
Save