Skip to content

Commit

Permalink
Changed Custom Status methods to check if the user is logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Jun 27, 2019
1 parent a48b69e commit 6dd129a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/user-status/server/methods/getUserStatusText.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { getStatusText } from '../../../lib';

Meteor.methods({
getUserStatusText(userId) {
const currentUserId = Meteor.userId();
if (!currentUserId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getUserStatusText' });
}

return getStatusText(userId);
},
});
5 changes: 5 additions & 0 deletions app/user-status/server/methods/listCustomUserStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { CustomUserStatus } from '../../../models';

Meteor.methods({
listCustomUserStatus() {
const currentUserId = Meteor.userId();
if (!currentUserId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'listCustomUserStatus' });
}

return CustomUserStatus.find({}).fetch();
},
});
6 changes: 5 additions & 1 deletion app/user-status/server/methods/setUserStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { RateLimiter, setStatusText } from '../../../lib';

Meteor.methods({
setUserStatus(statusType, statusText) {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'setUserStatus' });
}

if (statusType) {
Meteor.call('UserPresence:setDefaultStatus', statusType);
}
Expand All @@ -19,7 +24,6 @@ Meteor.methods({
});
}

const userId = Meteor.userId();
setStatusText(userId, statusText);
}
},
Expand Down

0 comments on commit 6dd129a

Please sign in to comment.