首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"cloudnest/internal/interface/http/handler"
|
||||
"cloudnest/internal/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RegisterAuthRoutes registers authentication-related routes.
|
||||
// RegisterAuthRoutes 注册认证相关的路由。
|
||||
//
|
||||
// Parameters:
|
||||
// - r: The router group to register routes on.
|
||||
// - h: The authentication handler.
|
||||
// - emailHandler: The email verification handler.
|
||||
//
|
||||
// Routes:
|
||||
// - POST /register: Register a new user.
|
||||
// - POST /login: Authenticate and get JWT token.
|
||||
// - POST /email-code: Send email verification code.
|
||||
// - GET /profile: Get user profile (requires JWT).
|
||||
// - PUT /profile: Update user profile (requires JWT).
|
||||
// - PUT /password: Change password (requires JWT).
|
||||
//
|
||||
// 参数:
|
||||
// - r: 要注册路由的路由器组。
|
||||
// - h: 认证处理器。
|
||||
// - emailHandler: 邮箱验证码处理器。
|
||||
//
|
||||
// 路由:
|
||||
// - POST /register: 注册新用户。
|
||||
// - POST /login: 认证并获取 JWT 令牌。
|
||||
// - POST /email-code: 发送邮箱验证码。
|
||||
// - GET /profile: 获取用户个人信息(需要 JWT)。
|
||||
// - PUT /profile: 更新用户个人信息(需要 JWT)。
|
||||
// - PUT /password: 修改密码(需要 JWT)。
|
||||
func RegisterAuthRoutes(r *gin.RouterGroup, h *handler.AuthHandler, emailHandler *handler.EmailHandler, jwtSecret string) {
|
||||
r.POST("/register", h.Register)
|
||||
r.POST("/login", h.Login)
|
||||
r.POST("/email-code", emailHandler.SendEmailCode)
|
||||
|
||||
protected := r.Group("")
|
||||
protected.Use(middleware.JWT(jwtSecret))
|
||||
protected.GET("/profile", h.Profile)
|
||||
protected.PUT("/profile", h.UpdateProfile)
|
||||
protected.PUT("/password", h.ChangePassword)
|
||||
}
|
||||
Reference in New Issue
Block a user