Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Add log when user log in

Smaug#67399bf2540730ea
diff --git a/backend/controllers/authentication.controller.go b/backend/controllers/authentication.controller.go
index 5e51af6b..573166ce 100644
--- a/backend/controllers/authentication.controller.go
+++ b/backend/controllers/authentication.controller.go
@@ -90,6 +90,15 @@ func (dc *AuthControllerImpl) Login(c *gin.Context) (int, any) {
c.SetCookie("RefreshToken", session.RefreshToken, int(time.Duration(dc.app.Config.Auth.RefreshTokenExpiry).Seconds()), "/", "localhost", false, true)
user.Password = ""
+ dc.log_service.CreateConnectionLog(&models.Log{
+ Id: dc.app.Snowflake.Generate(),
+ UserId: user.Id,
+ IpAddr: c.ClientIP(),
+ Timestamp: time.Now().UnixMilli(),
+ Type: "login",
+ Location: dc.log_service.GetLocationFromIp(c.ClientIP()),
+ })
+
return http.StatusOK, user
}