🎨 改进多工作空间鉴权

This commit is contained in:
Liang Ding 2023-01-10 22:25:02 +08:00
parent 59bd919b0c
commit 4e9e111ee7
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 33 additions and 11 deletions

View file

@ -30,6 +30,10 @@ func NeedCaptcha() bool {
// SessionData represents the session.
type SessionData struct {
Workspaces map[string]*WorkspaceSession // <WorkspacePath, WorkspaceSession>
}
type WorkspaceSession struct {
AccessAuthCode string
Captcha string
}
@ -63,3 +67,16 @@ func GetSession(c *gin.Context) *SessionData {
c.Set("session", ret)
return ret
}
func GetWorkspaceSession(session *SessionData) (ret *WorkspaceSession) {
ret = &WorkspaceSession{}
if nil == session.Workspaces {
session.Workspaces = map[string]*WorkspaceSession{}
}
ret = session.Workspaces[WorkspaceDir]
if nil == ret {
ret = &WorkspaceSession{}
session.Workspaces[WorkspaceDir] = ret
}
return
}