-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate auth and settings to graphQL (#19507)
- Loading branch information
Showing
180 changed files
with
4,618 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,4 +190,4 @@ select_permissions: | |
filter: | ||
meetingId: | ||
_eq: X-Hasura-MeetingId | ||
comment: "" | ||
comment: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ select_permissions: | |
filter: | ||
meetingId: | ||
_eq: X-Hasura-MeetingId | ||
comment: "" | ||
comment: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,4 +212,4 @@ update_permissions: | |
_eq: X-Hasura-MeetingId | ||
- userId: | ||
_eq: X-Hasura-UserId | ||
check: null | ||
check: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { | ||
Suspense, | ||
useContext, | ||
useEffect, | ||
} from 'react'; | ||
import { LoadingContext } from '/imports/ui/components/common/loading-screen/loading-screen-HOC/component'; | ||
import { defineMessages, useIntl } from 'react-intl'; | ||
|
||
const MeetingClientLazy = React.lazy(() => import('./meetingClient')); | ||
|
||
const intlMessages = defineMessages({ | ||
loadingClientLabel: { | ||
id: 'app.meeting.loadingClient', | ||
description: 'loading client label', | ||
}, | ||
}); | ||
|
||
const ClientStartup: React.FC = () => { | ||
const loadingContextInfo = useContext(LoadingContext); | ||
const intl = useIntl(); | ||
useEffect(() => { | ||
loadingContextInfo.setLoading(true, intl.formatMessage(intlMessages.loadingClientLabel)); | ||
}, []); | ||
|
||
return ( | ||
<Suspense> | ||
{ | ||
(() => { | ||
try { | ||
return <MeetingClientLazy />; | ||
} catch (error) { | ||
loadingContextInfo.setLoading(false, ''); | ||
throw new Error('Error on rendering MeetingClientLazy: '.concat(JSON.stringify(error) || '')); | ||
} | ||
})() | ||
} | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default ClientStartup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import ConnectionManager from '/imports/ui/components/connection-manager/component'; | ||
// eslint-disable-next-line react/no-deprecated | ||
import { render } from 'react-dom'; | ||
import SettingsLoader from '/imports/ui/components/settings-loader/component'; | ||
import ErrorBoundary from '/imports/ui/components/common/error-boundary/component'; | ||
import { ErrorScreen } from '/imports/ui/components/error-screen/component'; | ||
import PresenceManager from '/imports/ui/components/join-handler/presenceManager/component'; | ||
import LoadingScreenHOC from '/imports/ui/components/common/loading-screen/loading-screen-HOC/component'; | ||
import IntlLoaderContainer from '/imports/startup/client/intlLoader'; | ||
import LocatedErrorBoundary from '/imports/ui/components/common/error-boundary/located-error-boundary/component'; | ||
import StartupDataFetch from '/imports/ui/components/connection-manager/startup-data-fetch/component'; | ||
|
||
const Main: React.FC = () => { | ||
return ( | ||
<StartupDataFetch> | ||
<ErrorBoundary Fallback={ErrorScreen}> | ||
<LoadingScreenHOC> | ||
<IntlLoaderContainer> | ||
{/* from there the error messages are located */} | ||
<LocatedErrorBoundary Fallback={ErrorScreen}> | ||
<ConnectionManager> | ||
<PresenceManager> | ||
<SettingsLoader /> | ||
</PresenceManager> | ||
</ConnectionManager> | ||
</LocatedErrorBoundary> | ||
</IntlLoaderContainer> | ||
</LoadingScreenHOC> | ||
</ErrorBoundary> | ||
</StartupDataFetch> | ||
); | ||
}; | ||
|
||
render( | ||
<Main />, | ||
document.getElementById('app'), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
bigbluebutton-html5/imports/api/users/server/methods/validateConnection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Client } from 'pg'; | ||
import upsertValidationState from '/imports/api/auth-token-validation/server/modifiers/upsertValidationState'; | ||
import { ValidationStates } from '/imports/api/auth-token-validation'; | ||
import userJoin from '/imports/api/users/server/handlers/userJoin'; | ||
import Users from '/imports/api/users'; | ||
|
||
import createDummyUser from '../modifiers/createDummyUser'; | ||
import updateUserConnectionId from '../modifiers/updateUserConnectionId'; | ||
|
||
async function validateConnection(requesterToken, meetingId, userId) { | ||
try { | ||
const client = new Client({ | ||
host: process.env.POSTGRES_HOST || Meteor.settings.private.postgresql.host, | ||
port: process.env.POSTGRES_PORT || Meteor.settings.private.postgresql.port, | ||
database: process.env.POSTGRES_HOST || Meteor.settings.private.postgresql.database, | ||
user: process.env.POSTGRES_USER || Meteor.settings.private.postgresql.user, | ||
password: process.env.POSTGRES_PASSWORD || Meteor.settings.private.postgresql.password, | ||
query_timeout: process.env.POSTGRES_TIMEOUT || Meteor.settings.private.postgresql.timeout, | ||
}); | ||
|
||
await client.connect(); | ||
|
||
const res = await client.query('select "meetingId", "userId" from v_user_connection_auth where "authToken" = $1', [requesterToken]); | ||
|
||
if (res.rows.length === 0) { | ||
await upsertValidationState( | ||
meetingId, | ||
userId, | ||
ValidationStates.INVALID, | ||
this.connection.id, | ||
); | ||
} else { | ||
const sessionId = `${meetingId}--${userId}`; | ||
this.setUserId(sessionId); | ||
await upsertValidationState( | ||
meetingId, | ||
userId, | ||
ValidationStates.VALIDATED, | ||
this.connection.id, | ||
); | ||
|
||
const User = await Users.findOneAsync({ | ||
meetingId, | ||
userId, | ||
}); | ||
|
||
if (!User) { | ||
await createDummyUser(meetingId, userId, requesterToken); | ||
} else { | ||
await updateUserConnectionId(meetingId, userId, this.connection.id); | ||
} | ||
userJoin(meetingId, userId, requesterToken); | ||
} | ||
await client.end(); | ||
} catch (e) { | ||
await upsertValidationState( | ||
meetingId, | ||
userId, | ||
ValidationStates.INVALID, | ||
this.connection.id, | ||
); | ||
} | ||
} | ||
|
||
export default validateConnection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
bigbluebutton-html5/imports/startup/client/intlAdapter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { useContext, useEffect } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import Settings from '/imports/ui/services/settings'; | ||
import { Session } from 'meteor/session'; | ||
import { formatLocaleCode } from '/imports/utils/string-utils'; | ||
import Intl from '/imports/ui/services/locale'; | ||
import useCurrentLocale from '/imports/ui/core/local-states/useCurrentLocale'; | ||
import { LoadingContext } from '/imports/ui/components/common/loading-screen/loading-screen-HOC/component'; | ||
|
||
const RTL_LANGUAGES = ['ar', 'dv', 'fa', 'he']; | ||
const LARGE_FONT_LANGUAGES = ['te', 'km']; | ||
|
||
interface IntlAdapterProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const IntlAdapter: React.FC<IntlAdapterProps> = ({ | ||
children, | ||
}) => { | ||
const [currentLocale] = useCurrentLocale(); | ||
const intl = useIntl(); | ||
const loadingContextInfo = useContext(LoadingContext); | ||
const setUp = () => { | ||
if (currentLocale) { | ||
const { language, formattedLocale } = formatLocaleCode(currentLocale); | ||
// @ts-ignore - JS code | ||
Settings.application.locale = currentLocale; | ||
Intl.setLocale(formattedLocale, intl.messages); | ||
if (RTL_LANGUAGES.includes(currentLocale.substring(0, 2))) { | ||
// @ts-ignore - JS code | ||
document.body.parentNode.setAttribute('dir', 'rtl'); | ||
// @ts-ignore - JS code | ||
Settings.application.isRTL = true; | ||
} else { | ||
// @ts-ignore - JS code | ||
document.body.parentNode.setAttribute('dir', 'ltr'); | ||
// @ts-ignore - JS code | ||
Settings.application.isRTL = false; | ||
} | ||
Session.set('isLargeFont', LARGE_FONT_LANGUAGES.includes(currentLocale.substring(0, 2))); | ||
document.getElementsByTagName('html')[0].lang = formattedLocale; | ||
document.body.classList.add(`lang-${language}`); | ||
Settings.save(); | ||
} | ||
}; | ||
|
||
useEffect(setUp, []); | ||
useEffect(setUp, [currentLocale]); | ||
return !loadingContextInfo.isLoading ? children : null; | ||
}; | ||
|
||
export default IntlAdapter; |
Oops, something went wrong.