mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 00:56:37 +08:00
refactor(arch): decouple private imports, enforce contracts and comply with cordis architecture
This commit is contained in:
@@ -23,31 +23,51 @@ func passThrough() gin.HandlerFunc {
|
||||
return func(c *gin.Context) { c.Next() }
|
||||
}
|
||||
|
||||
func (s StubAuth) RequireAuthMiddleware() any { return passThrough() }
|
||||
// RequireAuthMiddleware returns a passthrough middleware.
|
||||
func (s StubAuth) RequireAuthMiddleware() any { return passThrough() }
|
||||
|
||||
// RequireAdminMiddleware returns a passthrough middleware.
|
||||
func (s StubAuth) RequireAdminMiddleware() any { return passThrough() }
|
||||
|
||||
// DisallowTokenAuthMiddleware returns a passthrough middleware.
|
||||
func (s StubAuth) DisallowTokenAuthMiddleware() any {
|
||||
return passThrough()
|
||||
}
|
||||
|
||||
// GetCurrentUser returns the stub user.
|
||||
func (s StubAuth) GetCurrentUser(context.Context) (*contracts.UserDTO, error) {
|
||||
return s.User, nil
|
||||
}
|
||||
|
||||
// GetCurrentUserID returns the stub user ID.
|
||||
func (s StubAuth) GetCurrentUserID(context.Context) (uint64, error) {
|
||||
if s.User == nil {
|
||||
return 0, nil
|
||||
}
|
||||
return s.User.ID, nil
|
||||
}
|
||||
|
||||
// VerifyToken returns the stub user.
|
||||
func (s StubAuth) VerifyToken(context.Context, string) (*contracts.UserDTO, error) {
|
||||
return s.User, nil
|
||||
}
|
||||
|
||||
// CreateSession creates a stub session.
|
||||
func (s StubAuth) CreateSession(context.Context, uint64, map[string]any) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
func (s StubAuth) RevokeToken(context.Context, string) error { return nil }
|
||||
|
||||
// RevokeToken revokes a stub token.
|
||||
func (s StubAuth) RevokeToken(context.Context, string) error { return nil }
|
||||
|
||||
// RevokeUserSessions revokes stub user sessions.
|
||||
func (s StubAuth) RevokeUserSessions(context.Context, uint64) error { return nil }
|
||||
func (s StubAuth) InvalidateCachedUser(context.Context, uint64) {}
|
||||
func (s StubAuth) InvalidateCachedToken(context.Context, string) {}
|
||||
|
||||
// InvalidateCachedUser invalidates stub cached user.
|
||||
func (s StubAuth) InvalidateCachedUser(context.Context, uint64) {}
|
||||
|
||||
// InvalidateCachedToken invalidates stub cached token.
|
||||
func (s StubAuth) InvalidateCachedToken(context.Context, string) {}
|
||||
func (s StubAuth) ListAuthSources(context.Context) ([]contracts.AuthSourceViewDTO, error) {
|
||||
return s.Sources, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user