answer/plugin/connector.go

50 lines
1.7 KiB
Go
Raw Permalink Normal View History

2022-12-30 10:21:41 +08:00
package plugin
type Connector interface {
Base
2023-01-10 16:43:42 +08:00
// ConnectorLogoSVG presents the logo in svg format
ConnectorLogoSVG() string
2022-12-30 10:21:41 +08:00
// ConnectorName presents the name of the connector
// e.g. Facebook, Twitter, Instagram
2023-02-20 11:46:44 +08:00
ConnectorName() Translator
2022-12-30 10:21:41 +08:00
// ConnectorSlugName presents the slug name of the connector
// Please use lowercase and hyphen as the separator
// e.g. facebook, twitter, instagram
ConnectorSlugName() string
// ConnectorSender presents the sender of the connector
// It handles the start endpoint of the connector
// receiverURL is the whole URL of the receiver
ConnectorSender(ctx *GinContext, receiverURL string) (redirectURL string)
2022-12-30 10:21:41 +08:00
// ConnectorReceiver presents the receiver of the connector
// It handles the callback endpoint of the connector, and returns the
ConnectorReceiver(ctx *GinContext, receiverURL string) (userInfo ExternalLoginUserInfo, err error)
2022-12-30 10:21:41 +08:00
}
// ExternalLoginUserInfo external login user info
type ExternalLoginUserInfo struct {
// required. The unique user ID provided by the third-party login
ExternalID string
// optional. This name is used preferentially during registration
DisplayName string
// optional. This username is used preferentially during registration
Username string
// optional. If email exist will bind the existing user
// IMPORTANT: The email must have been verified. If the plugin can't guarantee the email is verified, please leave it empty.
Email string
// optional. The avatar URL provided by the third-party login platform
Avatar string
// optional. The original user information provided by the third-party login platform
MetaInfo string
2022-12-30 10:21:41 +08:00
}
var (
// CallConnector is a function that calls all registered connectors
CallConnector,
2023-01-10 16:43:42 +08:00
registerConnector = MakePlugin[Connector](false)
2022-12-30 10:21:41 +08:00
)