fix: env + session to new db format
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/db"
|
||||
"github.com/authorizerdev/authorizer/server/db/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -16,13 +19,18 @@ func StringSliceContains(s []string, e string) bool {
|
||||
}
|
||||
|
||||
// SaveSessionInDB saves sessions generated for a given user with meta information
|
||||
// Not store token here as that could be security breach
|
||||
// Do not store token here as that could be security breach
|
||||
func SaveSessionInDB(userId string, c *gin.Context) {
|
||||
sessionData := db.Session{
|
||||
sessionData := models.Session{
|
||||
UserID: userId,
|
||||
UserAgent: GetUserAgent(c.Request),
|
||||
IP: GetIP(c.Request),
|
||||
}
|
||||
|
||||
db.Mgr.AddSession(sessionData)
|
||||
err := db.Provider.AddSession(&sessionData)
|
||||
if err != nil {
|
||||
log.Println("=> error saving session in db:", err)
|
||||
} else {
|
||||
log.Println("=> session saved in db:", sessionData)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user