lib

package
v0.0.0-...-5907adb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoogleConf = &oauth2.Config{
	ClientID:     config.GoogleClientID,
	ClientSecret: config.GoogleClientSecret,
	RedirectURL:  config.ServerURL + "/google-user/login",
	Scopes: []string{
		"https://www.googleapis.com/auth/userinfo.email",
		"https://www.googleapis.com/auth/userinfo.profile",
	},
	Endpoint: google.Endpoint,
}
View Source
var GoogleLoginURL = GoogleConf.AuthCodeURL(LoginState)
View Source
var GoogleRegisterURL = GoogleConf.AuthCodeURL(RegisterState)
View Source
var LoginState = RandToken()
View Source
var RegisterState = RandToken()

Functions

func Error

func Error(w http.ResponseWriter, statusCode int, message string)

func GoogleGetUserInfo

func GoogleGetUserInfo(code string) (models.User, error)

func HashPassword

func HashPassword(password string) (string, error)

func IsEmailValid

func IsEmailValid(e string) bool

func LogErrors

func LogErrors(errorLogFile string)

This function is set a log file All errors will be store in errorLogFile

func Mail

func Mail(email *mail.Email)

func RandToken

func RandToken() string

func SendRegisterMail

func SendRegisterMail(data map[string]any, to ...string) *mail.Email

func Success

func Success(w http.ResponseWriter, data any)

Types

type JwtStruct

type JwtStruct struct {
	SecretKey       string
	SessionLifetime time.Duration
}
var J JwtStruct

func (JwtStruct) GenerateJWT

func (j JwtStruct) GenerateJWT(cli map[string]any) (string, error)

Generate JWT token

func (JwtStruct) VerifyJWT

func (j JwtStruct) VerifyJWT(tokenString string) (jwt.MapClaims, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL