Let isStaff accept an undefined value
This commit is contained in:
parent
6ad116c0f9
commit
cafa014018
2 changed files with 10 additions and 1 deletions
|
@ -54,4 +54,11 @@ describe('isStaff', () => {
|
|||
expect(isStaff(mod)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with undefined', () => {
|
||||
const account = undefined;
|
||||
it('returns false', () => {
|
||||
expect(isStaff(account)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Map as ImmutableMap } from 'immutable';
|
||||
|
||||
export const getDomain = account => {
|
||||
let re = /https?:\/\/(.*?)\//i;
|
||||
return re.exec(account.get('url'))[1];
|
||||
|
@ -15,7 +17,7 @@ export const acctFull = account => {
|
|||
return [user, domain].join('@');
|
||||
};
|
||||
|
||||
export const isStaff = account => {
|
||||
export const isStaff = (account = ImmutableMap()) => {
|
||||
return ['is_admin', 'is_moderator'].some(key => (
|
||||
account.getIn(['pleroma', key]) === true
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue