- Add ALTCHA service with challenge generation and verification - Update auth and admin handlers to use ALTCHA tokens - Replace Turnstile widget with ALTCHA widget in Flutter app - Update admin frontend to use ALTCHA token - Add ALTCHA challenge endpoints for both auth and admin - Maintain development bypass for testing - Remove Turnstile dependencies from authentication flow
33 lines
833 B
Go
33 lines
833 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/patbritton/sojorn-backend/internal/services"
|
|
)
|
|
|
|
func (h *AdminHandler) GetAltchaChallenge(c *gin.Context) {
|
|
altchaService := services.NewAltchaService(h.jwtSecret) // Use JWT secret as ALTCHA secret for now
|
|
|
|
challenge, err := altchaService.GenerateChallenge()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to generate challenge"})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, challenge)
|
|
}
|
|
|
|
func (h *AuthHandler) GetAltchaChallenge(c *gin.Context) {
|
|
altchaService := services.NewAltchaService(h.config.JWTSecret)
|
|
|
|
challenge, err := altchaService.GenerateChallenge()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to generate challenge"})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, challenge)
|
|
}
|