make sure refreshed token is stored in the database when making raw unsafe requests.
This commit is contained in:
parent
956368ce3c
commit
6433de8f25
|
@ -8,5 +8,17 @@
|
||||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/fasten.db</jdbc-url>
|
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/fasten.db</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="fasten-jason" uuid="15be75d8-8739-4b19-927f-d8a23af95520">
|
||||||
|
<driver-ref>sqlite.xerial</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/fasten-jason.db</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
<libraries>
|
||||||
|
<library>
|
||||||
|
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.40.1/org/xerial/sqlite-jdbc/3.40.1.0/sqlite-jdbc-3.40.1.0.jar</url>
|
||||||
|
</library>
|
||||||
|
</libraries>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,11 +1,13 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/fastenhealth/fasten-sources/clients/factory"
|
"github.com/fastenhealth/fasten-sources/clients/factory"
|
||||||
sourcePkg "github.com/fastenhealth/fasten-sources/pkg"
|
sourcePkg "github.com/fastenhealth/fasten-sources/pkg"
|
||||||
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg"
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg"
|
||||||
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/config"
|
||||||
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database"
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database"
|
||||||
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -79,6 +81,22 @@ func UnsafeRequestSource(c *gin.Context) {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error(), "data": resp})
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error(), "data": resp})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update source incase the access token/refresh token has been updated
|
||||||
|
sourceCredential := client.GetSourceCredential()
|
||||||
|
sourceCredentialConcrete, ok := sourceCredential.(*models.SourceCredential)
|
||||||
|
if !ok {
|
||||||
|
logger.Errorln("An error occurred while updating source credential, source credential is not of type *models.SourceCredential")
|
||||||
|
c.JSON(http.StatusOK, gin.H{"success": false, "data": resp, "error": fmt.Errorf("An error occurred while updating source credential, source credential is not of type *models.SourceCredential")})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = databaseRepo.UpdateSource(c, sourceCredentialConcrete)
|
||||||
|
if err != nil {
|
||||||
|
logger.Errorf("An error occurred while updating source credential: %v", err)
|
||||||
|
c.JSON(http.StatusOK, gin.H{"success": false, "data": resp, "error": fmt.Errorf("An error occurred while updating source credential: %v", err)})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": resp})
|
c.JSON(http.StatusOK, gin.H{"success": true, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue