Documentation
¶
Index ¶
- type Hook
- type HookFunc
- type RecordAuthWithTelegramCreatedEvent
- type RecordTelegramLogin
- func (form *RecordTelegramLogin) GetAuthUserFromData() (*auth.AuthUser, error)
- func (form *RecordTelegramLogin) Submit(event *Hook[*RecordAuthWithTelegramCreatedEvent]) (*core.Record, *auth.AuthUser, error)
- func (form *RecordTelegramLogin) SubmitWithTelegramData(tgData *TelegramData, event *Hook[*RecordAuthWithTelegramCreatedEvent]) (*core.Record, *auth.AuthUser, error)
- func (form *RecordTelegramLogin) Validate() error
- type TelegramData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RecordAuthWithTelegramCreatedEvent ¶ added in v1.0.1
type RecordTelegramLogin ¶
type RecordTelegramLogin struct {
// Telegram data from window.Telegram.WebApp.initData in Web App
// This is URL encoded string with all telegram data.
// It should have hash inside
Data string `form:"data" json:"data"`
// The version of the Bot API available in the user's Telegram app. Can be empty
Version string `form:"version" json:"version"`
// The name of the platform of the user's Telegram app. Can be empty
Platform string `form:"platform" json:"platform"`
// Additional data that will be used for creating a new auth record
// if an existing Telegram account doesn't exist.
CreateData map[string]any `form:"createData" json:"createData"`
// contains filtered or unexported fields
}
RecordTelegramLogin is an auth record Telegram login form.
func NewRecordTelegramLogin ¶
func NewRecordTelegramLogin(app core.App, botToken string, collection *core.Collection, optAuthRecord *core.Record) *RecordTelegramLogin
NewRecordTelegramLogin creates a new RecordTelegramLogin form with initialized with from the provided core.App instance.
func (*RecordTelegramLogin) GetAuthUserFromData ¶
func (form *RecordTelegramLogin) GetAuthUserFromData() (*auth.AuthUser, error)
GetAuthUserFromData Parse Data url encoded values to the stuct with user data
func (*RecordTelegramLogin) Submit ¶
func (form *RecordTelegramLogin) Submit( event *Hook[*RecordAuthWithTelegramCreatedEvent], ) (*core.Record, *auth.AuthUser, error)
Submit validates and submits the form.
If an auth record doesn't exist, it will make an attempt to create it based on the fetched Telegram profile data via a local [RecordUpsert] form. You can intercept/modify the create form by setting the optional beforeCreateFuncs argument.
On success returns the authorized record model and the fetched provider's data.
func (*RecordTelegramLogin) SubmitWithTelegramData ¶
func (form *RecordTelegramLogin) SubmitWithTelegramData( tgData *TelegramData, event *Hook[*RecordAuthWithTelegramCreatedEvent], ) (*core.Record, *auth.AuthUser, error)
func (*RecordTelegramLogin) Validate ¶
func (form *RecordTelegramLogin) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.