@@ -147,8 +147,6 @@ func handleWebRTCSession(c *gin.Context) {
147
147
}
148
148
149
149
func handleLogin (c * gin.Context ) {
150
- LoadConfig ()
151
-
152
150
if config .LocalAuthMode == "noPassword" {
153
151
c .JSON (http .StatusBadRequest , gin.H {"error" : "Login is disabled in noPassword mode" })
154
152
return
@@ -161,7 +159,6 @@ func handleLogin(c *gin.Context) {
161
159
return
162
160
}
163
161
164
- LoadConfig ()
165
162
err := bcrypt .CompareHashAndPassword ([]byte (config .HashedPassword ), []byte (req .Password ))
166
163
if err != nil {
167
164
c .JSON (http .StatusUnauthorized , gin.H {"error" : "Invalid password" })
@@ -177,7 +174,6 @@ func handleLogin(c *gin.Context) {
177
174
}
178
175
179
176
func handleLogout (c * gin.Context ) {
180
- LoadConfig ()
181
177
config .LocalAuthToken = ""
182
178
if err := SaveConfig (); err != nil {
183
179
c .JSON (http .StatusInternalServerError , gin.H {"error" : "Failed to save configuration" })
@@ -191,8 +187,6 @@ func handleLogout(c *gin.Context) {
191
187
192
188
func protectedMiddleware () gin.HandlerFunc {
193
189
return func (c * gin.Context ) {
194
- LoadConfig ()
195
-
196
190
if config .LocalAuthMode == "noPassword" {
197
191
c .Next ()
198
192
return
@@ -221,8 +215,6 @@ func RunWebServer() {
221
215
}
222
216
223
217
func handleDevice (c * gin.Context ) {
224
- LoadConfig ()
225
-
226
218
response := LocalDevice {
227
219
AuthMode : & config .LocalAuthMode ,
228
220
DeviceID : GetDeviceID (),
@@ -232,8 +224,6 @@ func handleDevice(c *gin.Context) {
232
224
}
233
225
234
226
func handleCreatePassword (c * gin.Context ) {
235
- LoadConfig ()
236
-
237
227
if config .HashedPassword != "" {
238
228
c .JSON (http .StatusBadRequest , gin.H {"error" : "Password already set" })
239
229
return
@@ -274,8 +264,6 @@ func handleCreatePassword(c *gin.Context) {
274
264
}
275
265
276
266
func handleUpdatePassword (c * gin.Context ) {
277
- LoadConfig ()
278
-
279
267
if config .HashedPassword == "" {
280
268
c .JSON (http .StatusBadRequest , gin.H {"error" : "Password is not set" })
281
269
return
@@ -319,8 +307,6 @@ func handleUpdatePassword(c *gin.Context) {
319
307
}
320
308
321
309
func handleDeletePassword (c * gin.Context ) {
322
- LoadConfig ()
323
-
324
310
if config .HashedPassword == "" {
325
311
c .JSON (http .StatusBadRequest , gin.H {"error" : "Password is not set" })
326
312
return
@@ -357,8 +343,6 @@ func handleDeletePassword(c *gin.Context) {
357
343
}
358
344
359
345
func handleDeviceStatus (c * gin.Context ) {
360
- LoadConfig ()
361
-
362
346
response := DeviceStatus {
363
347
IsSetup : config .LocalAuthMode != "" ,
364
348
}
@@ -367,8 +351,6 @@ func handleDeviceStatus(c *gin.Context) {
367
351
}
368
352
369
353
func handleDeviceUIConfig (c * gin.Context ) {
370
- LoadConfig ()
371
-
372
354
config , _ := json .Marshal (gin.H {
373
355
"CLOUD_API" : config .CloudURL ,
374
356
"DEVICE_VERSION" : builtAppVersion ,
@@ -384,8 +366,6 @@ func handleDeviceUIConfig(c *gin.Context) {
384
366
}
385
367
386
368
func handleSetup (c * gin.Context ) {
387
- LoadConfig ()
388
-
389
369
// Check if the device is already set up
390
370
if config .LocalAuthMode != "" || config .HashedPassword != "" {
391
371
c .JSON (http .StatusBadRequest , gin.H {"error" : "Device is already set up" })
0 commit comments