feat: applied auth wirth session token on dart backend

This commit is contained in:
2025-01-04 14:50:08 +00:00
parent 55edac6abe
commit e9221f36ef
13 changed files with 146 additions and 236 deletions
@@ -106,15 +106,15 @@ func (s *AuthService) Logout(c *gin.Context) {
func setSessionTokenCookie(c *gin.Context, user entities.User) func(token string) string {
return func(token string) string {
c.SetCookie("session_token", token, 3600, "/", "localhost", false, true)
c.SetCookie("user_id", user.ID, 3600, "/", "localhost", false, true)
c.SetCookie("session_token", token, 3600, "/", "", false, true)
c.SetCookie("user_id", user.ID, 3600, "/", "", false, true)
return token
}
}
func deleteSessionTokenCookie(c *gin.Context) {
c.SetCookie("session_token", "", -1, "/", "localhost", false, true)
c.SetCookie("user_id", "", -1, "/", "localhost", false, true)
c.SetCookie("session_token", "", -1, "/", "", false, true)
c.SetCookie("user_id", "", -1, "/", "", false, true)
}
func validatePassword(password string) func(user entities.User) E.Either[error, entities.User] {
@@ -3,7 +3,7 @@ package dto
// TokenResponseDTO represents the response for a token generation or validation.
type TokenResponseDTO struct {
Token string `json:"token"`
UserID string `json:"user_id"`
UserID string `json:"userId"`
}
// LoginRequestDTO represents the login request.