@@ -57,7 +57,33 @@ func (c *Controller) UpdateProvider(ctx *fiber.Ctx) error {
5757}
5858
5959func (c * Controller ) GetMultiProviders (ctx * fiber.Ctx ) error {
60- return ctx .JSON (c .config .Providers )
60+ // Combine legacy provider config with new multi-provider config
61+ result := make (map [string ]* settings.ProviderConfig )
62+
63+ // First, add all providers from the new multi-provider map
64+ if c .config .Providers != nil {
65+ for name , config := range c .config .Providers {
66+ result [name ] = config
67+ }
68+ }
69+
70+ // Then, add the legacy provider if it exists and isn't already in the map
71+ if c .config .Provider != "" {
72+ if _ , exists := result [c .config .Provider ]; ! exists {
73+ result [c .config .Provider ] = & settings.ProviderConfig {
74+ Email : c .config .Email ,
75+ Password : c .config .Password ,
76+ PasswordFile : c .config .PasswordFile ,
77+ LoginToken : c .config .LoginToken ,
78+ LoginTokenFile : c .config .LoginTokenFile ,
79+ AppKey : c .config .AppKey ,
80+ AppSecret : c .config .AppSecret ,
81+ ConsumerKey : c .config .ConsumerKey ,
82+ }
83+ }
84+ }
85+
86+ return ctx .JSON (result )
6187}
6288
6389func (c * Controller ) UpdateMultiProviders (ctx * fiber.Ctx ) error {
@@ -66,6 +92,45 @@ func (c *Controller) UpdateMultiProviders(ctx *fiber.Ctx) error {
6692 return err
6793 }
6894
95+ // If there's a legacy provider configured, check if it's in the input
96+ if c .config .Provider != "" {
97+ if legacyConfig , hasLegacy := providers [c .config .Provider ]; hasLegacy {
98+ // Update the legacy top-level fields
99+ c .config .Email = legacyConfig .Email
100+ c .config .Password = legacyConfig .Password
101+ c .config .PasswordFile = legacyConfig .PasswordFile
102+ c .config .LoginToken = legacyConfig .LoginToken
103+ c .config .LoginTokenFile = legacyConfig .LoginTokenFile
104+ c .config .AppKey = legacyConfig .AppKey
105+ c .config .AppSecret = legacyConfig .AppSecret
106+ c .config .ConsumerKey = legacyConfig .ConsumerKey
107+
108+ // Create a new map with only the non-legacy providers
109+ nonLegacyProviders := make (map [string ]* settings.ProviderConfig )
110+ for name , config := range providers {
111+ if name != c .config .Provider {
112+ nonLegacyProviders [name ] = config
113+ }
114+ }
115+
116+ // Update the providers map with only non-legacy providers
117+ if len (nonLegacyProviders ) > 0 {
118+ c .config .Providers = nonLegacyProviders
119+ } else {
120+ // If no other providers, clear the providers map
121+ c .config .Providers = nil
122+ }
123+
124+ if err := c .config .SaveSettings (c .configPath ); err != nil {
125+ log .Errorf ("Failed to save settings: %s" , err .Error ())
126+ return ctx .Status (500 ).SendString ("Failed to save settings" )
127+ }
128+
129+ return ctx .SendStatus (fiber .StatusOK )
130+ }
131+ }
132+
133+ // No legacy provider match, update the entire providers map
69134 c .config .Providers = providers
70135
71136 if err := c .config .SaveSettings (c .configPath ); err != nil {
0 commit comments