mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
feat(session): generate temp URL to copy/refresh user session
This commit is contained in:
@@ -377,3 +377,23 @@ func UserInit2FA(c *gin.Context) {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// UserPrepareCopySession generates URL for copy session
|
||||
func UserPrepareCopySession(c *gin.Context) {
|
||||
var service user.CopySessionService
|
||||
res := service.Prepare(c, CurrentUser(c))
|
||||
c.JSON(200, res)
|
||||
|
||||
}
|
||||
|
||||
// UserPerformCopySession copy to create new session or refresh current session
|
||||
func UserPerformCopySession(c *gin.Context) {
|
||||
var service user.CopySessionService
|
||||
if err := c.ShouldBindUri(&service); err == nil {
|
||||
res := service.Copy(c)
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -233,6 +233,8 @@ func InitMasterRouter() *gin.Engine {
|
||||
// 打包并下载文件
|
||||
file.GET("archive/:sessionID/archive.zip", controllers.DownloadArchive)
|
||||
}
|
||||
|
||||
sign.GET("user/session/copy/:id", controllers.UserPerformCopySession)
|
||||
}
|
||||
|
||||
// 从机的 RPC 通信
|
||||
@@ -523,6 +525,9 @@ func InitMasterRouter() *gin.Engine {
|
||||
user.GET("storage", controllers.UserStorage)
|
||||
// 退出登录
|
||||
user.DELETE("session", controllers.UserSignOut)
|
||||
// Generate temp URL for copying client-side session, used in adding accounts
|
||||
// for mobile App.
|
||||
user.GET("session", controllers.UserPrepareCopySession)
|
||||
|
||||
// WebAuthn 注册相关
|
||||
authn := user.Group("authn",
|
||||
|
||||
Reference in New Issue
Block a user