Skip to content

Commit

Permalink
Fix issue in saving received creds
Browse files Browse the repository at this point in the history
  • Loading branch information
amalabey committed Dec 7, 2020
1 parent 3d6de22 commit bec6c02
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void setup()
Serial.println("SPIFFS Mount Failed");
return;
}
SPIFFS.format();
//SPIFFS.format();

// Load the configuration
Configuration _config;
Expand Down Expand Up @@ -103,9 +103,18 @@ void setup()
if (!_config.isPersisted(SPIFFS))
{
Credentials received = _client.getCredentials();
settings.userName = received.username;
settings.password = received.password;
settings.tenantId = received.tenant;
if(_userName != NULL) free(_userName);
_userName = strdup(received.username);

if(_password != NULL) free(_password);
_password = strdup(received.password);

if(_tenantId != NULL) free(_tenantId);
_tenantId = strdup(received.tenant);

settings.userName = _tenantId;
settings.password = _password;
settings.tenantId = _tenantId;
_config.persistSettings(SPIFFS, settings);
}

Expand Down

0 comments on commit bec6c02

Please sign in to comment.