2026-01-27 13:54:22 +05:30
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
* See the LICENSE file for details.
|
|
|
|
|
*/
|
|
|
|
|
|
[WEB-5657] feat: add synchronization configuration for multiple providers in authentication adapter (#8336)
* feat: add sync functionality for OAuth providers
- Implemented `check_sync_enabled` method to verify if sync is enabled for Google, GitHub, GitLab, and Gitea.
- Added `sync_user_data` method to update user details, including first name, last name, display name, and avatar.
- Updated configuration variables to include sync options for each provider.
- Integrated sync check into the login/signup process.
* feat: add sync toggle for OAuth providers in configuration forms
* fix: remove default value for sync options in OAuth configuration forms
* chore: delete old avatar and upload a new one
* chore: update class method
* chore: add email nullable
* refactor: streamline sync check for multiple providers and improve avatar deletion logic
* fix: ensure ENABLE_SYNC configurations default to "0" for Gitea, Github, Gitlab, and Google forms
* fix: simplify toggle switch value handling in ControllerSwitch component
---------
Co-authored-by: b-saikrishnakanth <bsaikrishnakanth97@gmail.com>
2025-12-22 12:23:39 +05:30
|
|
|
import type { Control, FieldPath, FieldValues } from "react-hook-form";
|
|
|
|
|
import { Controller } from "react-hook-form";
|
|
|
|
|
// plane internal packages
|
|
|
|
|
import { ToggleSwitch } from "@plane/ui";
|
|
|
|
|
|
|
|
|
|
type Props<T extends FieldValues = FieldValues> = {
|
|
|
|
|
control: Control<T>;
|
|
|
|
|
field: TControllerSwitchFormField<T>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type TControllerSwitchFormField<T extends FieldValues = FieldValues> = {
|
|
|
|
|
name: FieldPath<T>;
|
|
|
|
|
label: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function ControllerSwitch<T extends FieldValues>(props: Props<T>) {
|
|
|
|
|
const {
|
|
|
|
|
control,
|
|
|
|
|
field: { name, label },
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center justify-between gap-1">
|
|
|
|
|
<h4 className="text-sm text-custom-text-300">Refresh user attributes from {label} during sign in</h4>
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<Controller
|
|
|
|
|
control={control}
|
|
|
|
|
name={name as FieldPath<T>}
|
2025-12-22 12:55:19 +05:30
|
|
|
render={({ field: { value, onChange } }) => {
|
|
|
|
|
const parsedValue = Number.parseInt(typeof value === "string" ? value : String(value ?? "0"), 10);
|
|
|
|
|
const isOn = !Number.isNaN(parsedValue) && parsedValue !== 0;
|
|
|
|
|
return <ToggleSwitch value={isOn} onChange={() => onChange(isOn ? "0" : "1")} size="sm" />;
|
|
|
|
|
}}
|
[WEB-5657] feat: add synchronization configuration for multiple providers in authentication adapter (#8336)
* feat: add sync functionality for OAuth providers
- Implemented `check_sync_enabled` method to verify if sync is enabled for Google, GitHub, GitLab, and Gitea.
- Added `sync_user_data` method to update user details, including first name, last name, display name, and avatar.
- Updated configuration variables to include sync options for each provider.
- Integrated sync check into the login/signup process.
* feat: add sync toggle for OAuth providers in configuration forms
* fix: remove default value for sync options in OAuth configuration forms
* chore: delete old avatar and upload a new one
* chore: update class method
* chore: add email nullable
* refactor: streamline sync check for multiple providers and improve avatar deletion logic
* fix: ensure ENABLE_SYNC configurations default to "0" for Gitea, Github, Gitlab, and Google forms
* fix: simplify toggle switch value handling in ControllerSwitch component
---------
Co-authored-by: b-saikrishnakanth <bsaikrishnakanth97@gmail.com>
2025-12-22 12:23:39 +05:30
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|