添加配置加载和授权服务初始化,更新授权模型引用,重构授权文件生成和处理逻辑,优化 TOTP 密钥生成及错误处理

This commit is contained in:
zeaslity
2025-03-13 10:36:23 +08:00
parent 25dbc87a73
commit 34147b2f69
5 changed files with 133 additions and 55 deletions

View File

@@ -1,10 +1,11 @@
package controllers
import (
models2 "cmii-uav-watchdog-common/models"
"cmii-uav-watchdog/models"
"cmii-uav-watchdog/services"
"net/http"
"github.com/gin-gonic/gin"
)
@@ -32,7 +33,7 @@ func (ac *AuthController) GenerateAuthFile(c *gin.Context) {
})
return
}
c.JSON(http.StatusOK, models.Response{
Code: 200,
Message: "生成授权文件成功",
@@ -42,7 +43,7 @@ func (ac *AuthController) GenerateAuthFile(c *gin.Context) {
// ReceiveAuthCode 接收授权码
func (ac *AuthController) ReceiveAuthCode(c *gin.Context) {
var authCode models.AuthorizationCode
var authCode models2.AuthorizationCode
if err := c.ShouldBindJSON(&authCode); err != nil {
c.JSON(http.StatusBadRequest, models.Response{
Code: 400,
@@ -51,7 +52,7 @@ func (ac *AuthController) ReceiveAuthCode(c *gin.Context) {
})
return
}
// 处理授权码
err := ac.authService.ProcessAuthorizationCode(authCode)
if err != nil {
@@ -62,7 +63,7 @@ func (ac *AuthController) ReceiveAuthCode(c *gin.Context) {
})
return
}
c.JSON(http.StatusOK, models.Response{
Code: 200,
Message: "处理授权码成功",
@@ -74,7 +75,7 @@ func (ac *AuthController) ReceiveAuthCode(c *gin.Context) {
func (ac *AuthController) NotifyAuthInfo(c *gin.Context) {
// 获取授权信息
authInfo := ac.authService.GetAuthorizationInfo()
c.JSON(http.StatusOK, models.Response{
Code: 200,
Message: "获取授权信息成功",