mirror of
https://github.com/khoaliber/LetterFeed.git
synced 2026-03-02 13:18:27 +00:00
fix: #20
This commit is contained in:
@@ -113,6 +113,9 @@ def create_or_update_settings(db: Session, settings: SettingsCreate):
|
|||||||
db_settings.auth_password_hash = get_password_hash(value)
|
db_settings.auth_password_hash = get_password_hash(value)
|
||||||
else:
|
else:
|
||||||
db_settings.auth_password_hash = None
|
db_settings.auth_password_hash = None
|
||||||
|
elif key == "imap_password":
|
||||||
|
if value: # Only update password if a new one is provided
|
||||||
|
setattr(db_settings, key, value)
|
||||||
elif hasattr(db_settings, key):
|
elif hasattr(db_settings, key):
|
||||||
setattr(db_settings, key, value)
|
setattr(db_settings, key, value)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class SettingsBase(BaseModel):
|
|||||||
class SettingsCreate(SettingsBase):
|
class SettingsCreate(SettingsBase):
|
||||||
"""Schema for creating or updating settings, including the IMAP password."""
|
"""Schema for creating or updating settings, including the IMAP password."""
|
||||||
|
|
||||||
imap_password: str
|
imap_password: str | None = None
|
||||||
auth_password: str | None = None
|
auth_password: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,11 @@ export function SettingsDialog({
|
|||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!currentSettings) return
|
if (!currentSettings) return
|
||||||
try {
|
try {
|
||||||
await updateSettings(currentSettings)
|
const payload: SettingsCreate = { ...currentSettings }
|
||||||
|
if (payload.imap_password === "") {
|
||||||
|
delete payload.imap_password
|
||||||
|
}
|
||||||
|
await updateSettings(payload)
|
||||||
toast.success("Settings saved successfully!")
|
toast.success("Settings saved successfully!")
|
||||||
onOpenChange(false)
|
onOpenChange(false)
|
||||||
onSuccess()
|
onSuccess()
|
||||||
@@ -140,7 +144,7 @@ export function SettingsDialog({
|
|||||||
<Input
|
<Input
|
||||||
id="imap-password"
|
id="imap-password"
|
||||||
type="password"
|
type="password"
|
||||||
value={currentSettings.imap_password}
|
value={currentSettings.imap_password ?? ""}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
handleSettingsChange("imap_password", e.target.value)
|
handleSettingsChange("imap_password", e.target.value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export interface Settings {
|
|||||||
export interface SettingsCreate {
|
export interface SettingsCreate {
|
||||||
imap_server: string;
|
imap_server: string;
|
||||||
imap_username: string;
|
imap_username: string;
|
||||||
imap_password?: string;
|
imap_password?: string | null;
|
||||||
search_folder: string;
|
search_folder: string;
|
||||||
move_to_folder?: string | null;
|
move_to_folder?: string | null;
|
||||||
mark_as_read: boolean;
|
mark_as_read: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user