2024-01-11 14:31:36 -07:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/fastenhealth/fasten-onprem/backend/pkg"
|
|
|
|
"github.com/fastenhealth/fasten-onprem/backend/pkg/database"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-01-26 23:01:34 -07:00
|
|
|
// UX: this is a secure endpoint, and should only be called after a double confirmation
|
2024-01-11 14:31:36 -07:00
|
|
|
func DeleteAccount(c *gin.Context) {
|
|
|
|
logger := c.MustGet(pkg.ContextKeyTypeLogger).(*logrus.Entry)
|
|
|
|
databaseRepo := c.MustGet(pkg.ContextKeyTypeDatabase).(database.DatabaseRepository)
|
|
|
|
|
|
|
|
err := databaseRepo.DeleteCurrentUser(c)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
logger.Errorln("An error occurred while deleting current user", err)
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"success": true})
|
|
|
|
}
|