Documentation ¶
Index ¶
- Variables
- func ConfigInit(config *entities.Configuration) error
- func FromJSON(payload interface{}, reader io.Reader) error
- func ToJSON(payload interface{}, writer io.Writer) error
- type Claims
- type Credentials
- func (cred *Credentials) CreateO2AuthUser(rw http.ResponseWriter, r *http.Request, store *mysqlstore.MySQLStore, ...) error
- func (cred *Credentials) GenerateJWT(rw http.ResponseWriter, r *http.Request, store *mysqlstore.MySQLStore, ...) error
- func (cred *Credentials) GenerateOTP() (string, error)
- func (cred *Credentials) GetCurrentUser(rw http.ResponseWriter, r *http.Request, store *mysqlstore.MySQLStore) (*database.MasterUser, error)
- func (cred *Credentials) GetFacebookUserInfo(code string) ([]byte, error)
- func (cred *Credentials) GetGoogleUserInfo(accessToken string) ([]byte, error)
- func (cred *Credentials) SendOTP(rw http.ResponseWriter, r *http.Request, user *database.MasterUser, ...) (string, error)
Constants ¶
This section is empty.
Variables ¶
var MySigningKey string
MySigningKey is a variable that defines JWT secret
Functions ¶
func ConfigInit ¶
func ConfigInit(config *entities.Configuration) error
ConfigInit is a function to initialize app configuration
Types ¶
type Claims ¶
type Claims struct { Username string jwt.StandardClaims }
Claims determine the token holder
type Credentials ¶
type Credentials struct {
// contains filtered or unexported fields
}
Credentials defines a struct for credentials flow
func NewCredentials ¶
func NewCredentials(waClient waProtos.WhatsAppClient, emailClient protos.EmailClient, emailHandler *mailer.Email, newLogger hclog.Logger, newFacebookOauthConfig *oauth2.Config) *Credentials
NewCredentials is a function to create new credentials struct
func (*Credentials) CreateO2AuthUser ¶
func (cred *Credentials) CreateO2AuthUser(rw http.ResponseWriter, r *http.Request, store *mysqlstore.MySQLStore, providerID, provider, email, name string) error
CreateO2AuthUser is a function to create O2Auth user based on the given login provider
func (*Credentials) GenerateJWT ¶
func (cred *Credentials) GenerateJWT(rw http.ResponseWriter, r *http.Request, store *mysqlstore.MySQLStore, username string) error
GenerateJWT Generates a JWT token by validating the signing key
func (*Credentials) GenerateOTP ¶
func (cred *Credentials) GenerateOTP() (string, error)
GenerateOTP Generates an OTP code string
func (*Credentials) GetCurrentUser ¶
func (cred *Credentials) GetCurrentUser(rw http.ResponseWriter, r *http.Request, store *mysqlstore.MySQLStore) (*database.MasterUser, error)
GetCurrentUser will get the current user login info
func (*Credentials) GetFacebookUserInfo ¶
func (cred *Credentials) GetFacebookUserInfo(code string) ([]byte, error)
GetFacebookUserInfo process the facebook OAuth2 user info
func (*Credentials) GetGoogleUserInfo ¶
func (cred *Credentials) GetGoogleUserInfo(accessToken string) ([]byte, error)
GetGoogleUserInfo process the google OAuth2 user info
func (*Credentials) SendOTP ¶
func (cred *Credentials) SendOTP(rw http.ResponseWriter, r *http.Request, user *database.MasterUser, store *mysqlstore.MySQLStore) (string, error)
SendOTP is a function to send OTP to either users email or phone number (WA)