Skip to content

Commit

Permalink
fix #834
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jan 22, 2025
1 parent 6169e65 commit 3727321
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/components/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Announce from '../Announce/Announce';
import { InviteButton } from '../InviteButton/InviteButton';
import appStyles from '../App/App.module.css';
import { MetadataContext } from '../../MetadataContext';
import config from '../../config';

export async function createRoom(
user: firebase.User | undefined,
Expand Down Expand Up @@ -133,6 +134,27 @@ export class SignInButton extends React.Component<SignInButtonProps> {
</div>
);
}
const enabledOptions = config.VITE_FIREBASE_SIGNIN_METHODS.split(',');
const components: Record<string, JSX.Element> = {
facebook: (
<Dropdown.Item onClick={this.facebookSignIn}>
<Icon name="facebook" />
Facebook
</Dropdown.Item>
),
google: (
<Dropdown.Item onClick={this.googleSignIn}>
<Icon name="google" />
Google
</Dropdown.Item>
),
email: (
<Dropdown.Item onClick={() => this.setState({ isLoginOpen: true })}>
<Icon name="mail" />
Email
</Dropdown.Item>
),
};
return (
<React.Fragment>
{this.state.isLoginOpen && (
Expand All @@ -154,20 +176,9 @@ export class SignInButton extends React.Component<SignInButtonProps> {
fluid={this.props.fluid}
>
<Dropdown.Menu>
<Dropdown.Item onClick={this.facebookSignIn}>
<Icon name="facebook" />
Facebook
</Dropdown.Item>
<Dropdown.Item onClick={this.googleSignIn}>
<Icon name="google" />
Google
</Dropdown.Item>
<Dropdown.Item
onClick={() => this.setState({ isLoginOpen: true })}
>
<Icon name="mail" />
Email
</Dropdown.Item>
{enabledOptions.map((opt) => {
return components[opt];
})}
</Dropdown.Menu>
</Dropdown>
}
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default {
VITE_RECAPTCHA_SITE_KEY:
import.meta.env.VITE_RECAPTCHA_SITE_KEY ??
'6LeDGP4UAAAAAGYZZenyU-3fRdhL3p0BaBmiK9mM',
VITE_FIREBASE_SIGNIN_METHODS: 'facebook,google,email',
NODE_ENV: import.meta.env.DEV ? 'development' : 'production',
};

0 comments on commit 3727321

Please sign in to comment.