Documentation ¶
Index ¶
- type RecordTelegramLogin
- func (form *RecordTelegramLogin) GetAuthUserFromData() (*auth.AuthUser, error)
- func (form *RecordTelegramLogin) SetDao(dao *daos.Dao)
- func (form *RecordTelegramLogin) Submit(...) (*models.Record, *auth.AuthUser, error)
- func (form *RecordTelegramLogin) SubmitWithTelegramData(tgData *TelegramData, ...) (*models.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 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 *models.Collection, optAuthRecord *models.Record) *RecordTelegramLogin
NewRecordTelegramLogin creates a new RecordTelegramLogin form with initialized with from the provided core.App instance.
If you want to submit the form as part of a transaction, you can change the default Dao via [SetDao()].
func (*RecordTelegramLogin) GetAuthUserFromData ¶
func (form *RecordTelegramLogin) GetAuthUserFromData() (*auth.AuthUser, error)
GetAuthUserFromData Parse Data url encoded values to the stuct with user data
func (*RecordTelegramLogin) SetDao ¶
func (form *RecordTelegramLogin) SetDao(dao *daos.Dao)
SetDao replaces the default form Dao instance with the provided one.
func (*RecordTelegramLogin) Submit ¶
func (form *RecordTelegramLogin) Submit( beforeCreateFuncs ...func(createForm *pbForms.RecordUpsert, authRecord *models.Record, authUser *auth.AuthUser) error, ) (*models.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, beforeCreateFuncs ...func(createForm *pbForms.RecordUpsert, authRecord *models.Record, authUser *auth.AuthUser) error, ) (*models.Record, *auth.AuthUser, error)
func (*RecordTelegramLogin) Validate ¶
func (form *RecordTelegramLogin) Validate() error
Validate makes the form validatable by implementing validation.Validatable interface.