Skip to content

Commit

Permalink
Merge branch 'develop' into test/decouple-roles
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Mar 28, 2024
2 parents 07f9ac8 + 7f65cf0 commit 0715718
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 88 deletions.
7 changes: 7 additions & 0 deletions .changeset/fuzzy-cherries-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@rocket.chat/meteor": major
---

Api login should not suggest which credential is wrong (password/username)

Failed login attemps will always return `Unauthorized` instead of the internal fail reason
5 changes: 5 additions & 0 deletions .changeset/strong-bananas-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed duplicate API calls during livechat room forwarding by adding loading state for submit button
6 changes: 6 additions & 0 deletions .changeset/two-suns-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/i18n': minor
'@rocket.chat/meteor': minor
---

feat: `ConnectionStatusBar` redesign
1 change: 0 additions & 1 deletion .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ runs:
cache: 'yarn'

- name: yarn install
if: steps.cache-node-modules.outputs.cache-hit != 'true'
shell: bash
run: yarn
14 changes: 0 additions & 14 deletions apps/meteor/app/lib/server/lib/loginErrorMessageOverride.js

This file was deleted.

16 changes: 16 additions & 0 deletions apps/meteor/app/lib/server/lib/loginErrorMessageOverride.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Do not disclose if user exists when password is invalid
import { Accounts } from 'meteor/accounts-base';
import { Meteor } from 'meteor/meteor';

const { _runLoginHandlers } = Accounts;

Accounts._options.ambiguousErrorMessages = true;
Accounts._runLoginHandlers = async function (methodInvocation, options) {
const result = await _runLoginHandlers.call(Accounts, methodInvocation, options);

if (result.error instanceof Meteor.Error) {
result.error = new Meteor.Error(401, 'User not found');
}

return result;
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ const ForwardChatModal = ({
const getUserData = useEndpoint('GET', '/v1/users.info');
const idleAgentsAllowedForForwarding = useSetting('Livechat_enabled_when_agent_idle') as boolean;

const { getValues, handleSubmit, register, setFocus, setValue, watch } = useForm();
const {
getValues,
handleSubmit,
register,
setFocus,
setValue,
watch,
formState: { isSubmitting },
} = useForm();

useEffect(() => {
setFocus('comment');
Expand Down Expand Up @@ -71,7 +79,7 @@ const ForwardChatModal = ({
uid = user?._id;
}

onForward(departmentId, uid, comment);
await onForward(departmentId, uid, comment);
},
[getUserData, onForward],
);
Expand Down Expand Up @@ -146,7 +154,7 @@ const ForwardChatModal = ({
<Modal.Footer>
<Modal.FooterControllers>
<Button onClick={onCancel}>{t('Cancel')}</Button>
<Button type='submit' disabled={!username && !department} primary>
<Button type='submit' disabled={!username && !department} primary loading={isSubmitting}>
{t('Forward')}
</Button>
</Modal.FooterControllers>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
import { Box, Icon } from '@rocket.chat/fuselage';
import { css } from '@rocket.chat/css-in-js';
import { Box, Button, Icon, Palette } from '@rocket.chat/fuselage';
import { useConnectionStatus } from '@rocket.chat/ui-contexts';
import type { MouseEvent } from 'react';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useReconnectCountdown } from './useReconnectCountdown';

const connectionStatusBarStyle = css`
color: ${Palette.statusColor['status-font-on-warning']};
background-color: ${Palette.surface['surface-tint']};
border-color: ${Palette.statusColor['status-font-on-warning']};
position: fixed;
z-index: 1000000;
display: flex;
justify-content: space-between;
align-items: center;
.rcx-connection-status-bar--wrapper {
display: flex;
align-items: center;
column-gap: 8px;
}
.rcx-connection-status-bar--content {
display: flex;
align-items: center;
column-gap: 8px;
}
.rcx-connection-status-bar--info {
color: ${Palette.text['font-default']};
}
`;
function ConnectionStatusBar() {
const { connected, retryTime, status, reconnect } = useConnectionStatus();
const reconnectCountdown = useReconnectCountdown(retryTime, status);
Expand All @@ -15,37 +41,32 @@ function ConnectionStatusBar() {
return null;
}

const handleRetryClick = (event: MouseEvent<HTMLAnchorElement>) => {
event.preventDefault();
reconnect?.();
};

return (
<Box
color='status-font-on-warning'
bg='status-background-warning'
position='fixed'
zIndex={1000000}
className={connectionStatusBarStyle}
rcx-connection-status-bar
insetBlockStart={0}
p={2}
pb={4}
pi={12}
width='100%'
textAlign='center'
borderBlockEndWidth={1}
borderBlockEndWidth={2}
role='alert'
fontScale='p2'
>
<Icon name='warning' />{' '}
<Box is='span' withRichContent>
<strong>{t('meteor_status', { context: status })}</strong>
{status === 'waiting' && <> {t('meteor_status_reconnect_in', { count: reconnectCountdown })}</>}
{['waiting', 'offline'].includes(status) && (
<>
{' '}
<a href='#' onClick={handleRetryClick} role='button'>
{t('meteor_status_try_now', { context: status })}
</a>
</>
)}
</Box>
<span className='rcx-connection-status-bar--wrapper'>
<Icon name='warning' />
<span className='rcx-connection-status-bar--content'>
<strong>{t('meteor_status', { context: status })}</strong>
{['waiting', 'failed', 'offline'].includes(status) && (
<span className='rcx-connection-status-bar--info'>
{status === 'waiting' ? t('meteor_status_reconnect_in', { count: reconnectCountdown }) : t('meteor_status_try_again_later')}
</span>
)}
</span>
</span>
<Button primary onClick={reconnect} small disabled={['connected', 'connecting'].includes(status)}>
{t('Connect')}
</Button>
</Box>
);
}
Expand Down
10 changes: 0 additions & 10 deletions apps/meteor/client/meteorOverrides/login/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ import { overrideLoginMethod, type LoginCallback } from '../../lib/2fa/overrideL
import { wrapRequestCredentialFn } from '../../lib/wrapRequestCredentialFn';
import { createOAuthTotpLoginMethod } from './oauth';

declare module 'meteor/accounts-base' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Accounts {
export const _options: {
restrictCreationByEmailDomain?: string | (() => string);
forbidClientAccountCreation?: boolean | undefined;
};
}
}

declare module 'meteor/meteor' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Meteor {
Expand Down
10 changes: 9 additions & 1 deletion apps/meteor/definition/externals/meteor/accounts-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare module 'meteor/accounts-base' {

function _insertLoginToken(userId: string, token: { token: string; when: Date }): void;

function _runLoginHandlers<T>(methodInvocation: T, loginRequest: Record<string, any>): LoginMethodResult | undefined;
function _runLoginHandlers<T>(methodInvocation: T, loginRequest: Record<string, any>): Promise<LoginMethodResult>;

function registerLoginHandler(name: string, handler: (options: any) => undefined | object): void;

Expand Down Expand Up @@ -54,6 +54,14 @@ declare module 'meteor/accounts-base' {

const _accountData: Record<string, any>;

interface AccountsServerOptions {
ambiguousErrorMessages?: boolean;
restrictCreationByEmailDomain?: string | (() => string);
forbidClientAccountCreation?: boolean | undefined;
}

export const _options: AccountsServerOptions;

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace oauth {
function credentialRequestCompleteHandler(
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/server/models/ReadReceipts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { registerModel } from '@rocket.chat/models';

import { ReadReceiptsDummy } from './dummy/ReadReceipts';

registerModel('IReadReceiptsModel', new ReadReceiptsDummy(), false);
Loading

0 comments on commit 0715718

Please sign in to comment.