Merge pull request #7444 from RocketChat/anonymous-user-join

[FIX] Fix Anonymous User
pull/7690/head
Rodrigo Nascimento 8 years ago
parent 112baa031e
commit 304be18d99
  1. 2
      packages/rocketchat-ui-flextab/client/tabs/membersList.js
  2. 4
      packages/rocketchat-ui-message/client/message.js
  3. 24
      packages/rocketchat-ui-message/client/messageBox.js
  4. 14
      packages/rocketchat-ui/client/views/app/room.js

@ -26,7 +26,7 @@ Template.membersList.helpers({
const roomUsers = Template.instance().users.get();
const room = ChatRoom.findOne(this.rid);
const roomMuted = (room != null ? room.muted : undefined) || [];
const userUtcOffset = Meteor.user().utcOffset;
const userUtcOffset = Meteor.user() && Meteor.user().utcOffset;
let totalOnline = 0;
let users = roomUsers.map(function(user) {
let utcOffset;

@ -13,7 +13,7 @@ Template.message.helpers({
roleTags() {
const user = Meteor.user();
// test user -> settings -> preferences -> hideRoles
if (!RocketChat.settings.get('UI_DisplayRoles') || ['settings', 'preferences', 'hideRoles'].reduce((obj, field) => typeof obj !== 'undefined' && obj[field], user)) {
if (!RocketChat.settings.get('UI_DisplayRoles') || (user && ['settings', 'preferences', 'hideRoles'].reduce((obj, field) => typeof obj !== 'undefined' && obj[field], user))) {
return [];
}
@ -205,7 +205,7 @@ Template.message.helpers({
return true;
},
reactions() {
const userUsername = Meteor.user().username;
const userUsername = Meteor.user() && Meteor.user().username;
return Object.keys(this.reactions||{}).map(emoji => {
const reaction = this.reactions[emoji];
const total = reaction.usernames.length;

@ -54,7 +54,7 @@ Template.messageBox.helpers({
return RocketChat.settings.get('Message_ShowFormattingTips') && (RocketChat.Markdown || RocketChat.MarkdownCode || katexSyntax());
},
canJoin() {
return RocketChat.roomTypes.verifyShowJoinLink(this._id);
return Meteor.userId() && RocketChat.roomTypes.verifyShowJoinLink(this._id);
},
joinCodeRequired() {
const code = Session.get(`roomData${ this._id }`);
@ -179,6 +179,13 @@ Template.messageBox.helpers({
},
showSandstorm() {
return Meteor.settings['public'].sandstorm && !Meteor.isCordova;
},
anonymousRead() {
return (Meteor.userId() == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true;
},
anonymousWrite() {
return (Meteor.userId() == null) && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true && RocketChat.settings.get('Accounts_AllowAnonymousWrite') === true;
}
});
@ -248,6 +255,21 @@ Template.messageBox.events({
}
});
},
'click .register'(event) {
event.stopPropagation();
event.preventDefault();
return Session.set('forceLogin', true);
},
'click .register-anonymous'(event) {
event.stopPropagation();
event.preventDefault();
return Meteor.call('registerUser', {}, function(error, loginData) {
if (loginData && loginData.token) {
return Meteor.loginWithToken(loginData.token);
}
});
},
'focus .input-message'(event, instance) {
KonchatNotification.removeRoomNotification(this._id);
chatMessages[this._id].input = instance.find('.input-message');

@ -224,11 +224,16 @@ Template.room.helpers({
return true;
}
if (RocketChat.settings.get('Accounts_AllowAnonymousRead') === true) {
return true;
}
if (RocketChat.authz.hasAllPermission('preview-c-room')) {
return true;
}
return (RocketChat.models.Subscriptions.findOne({rid: this._id}) != null);
}
});
@ -393,11 +398,17 @@ Template.room.events({
},
'click .flex-tab .user-image > button'(e, instance) {
if (!Meteor.userId()) {
return;
}
instance.tabBar.open();
return instance.setUserDetail(this.user.username);
},
'click .user-card-message'(e, instance) {
if (!Meteor.userId()) {
return;
}
const roomData = Session.get(`roomData${ this._arguments[1].rid }`);
if (RocketChat.Layout.isEmbedded()) {
@ -465,6 +476,9 @@ Template.room.events({
},
'click .mention-link'(e, instance) {
if (!Meteor.userId()) {
return;
}
const channel = $(e.currentTarget).data('channel');
if (channel != null) {
if (RocketChat.Layout.isEmbedded()) {

Loading…
Cancel
Save