app

package
v0.0.0-...-8495d1f Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitHubClient

func GetGitHubClient(token oauth2.Token) (*github.Client, error)

func SetDevConfig

func SetDevConfig(config *Config)

SetDevConfig create config for local dev mode.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App contains all the business logic as methods.

func NewApp

func NewApp(logger logrus.FieldLogger, store store.Store, config Config, userService UserService) *App

NewApp creates a new instance of App

func (*App) Clone

func (a *App) Clone() *App

Clone creates a shallow copy of app

func (*App) Config

func (a *App) Config() Config

Config is an accessor for the app config.

func (*App) CreateAndStoreResetPasswordToken

func (a *App) CreateAndStoreResetPasswordToken(email string) (*model.Token, error)

CreateAndStoreResetPasswordToken creates a new password reset token and stores it.

func (*App) CreateAndStoreVerifyEmailToken

func (a *App) CreateAndStoreVerifyEmailToken(email string) (*model.Token, error)

CreateAndStoreVerifyEmailToken creates a new verify email token and stores it.

func (*App) CreateOAuthState

func (a *App) CreateOAuthState() (*model.OAuthState, error)

func (*App) GetHTMLTemplate

func (a *App) GetHTMLTemplate(templateName string) *HTMLTemplate

GetHTMLTemplate returns the HTMLTemplate of a give name.

func (*App) GetOAuthConfig

func (a *App) GetOAuthConfig() *oauth2.Config

func (*App) GetOAuthState

func (a *App) GetOAuthState(idOrToken string) (*model.OAuthState, error)

func (*App) GithubConnectToken

func (a *App) GithubConnectToken(token oauth2.Token) (*github.Client, error)

func (*App) HTMLTemplates

func (a *App) HTMLTemplates() *template.Template

HTMLTemplates is an accessor for the app html templates.

func (*App) Logger

func (a *App) Logger() logrus.FieldLogger

func (*App) ReloadHTMLTemplates

func (a *App) ReloadHTMLTemplates() error

ReloadHTMLTemplates refreshes the in-memory HTML templates.

func (*App) SendMail

func (a *App) SendMail(to, subject, htmlBody string, sendBcc bool) error

SendMail sends mail.

func (*App) SendMailWithAttachments

func (a *App) SendMailWithAttachments(to, subject, htmlBody string, sendBcc bool, attachments []*email.Attachment) error

SendEmailWithAttachments would send the email including the passed attachments

func (*App) SendPasswordResetEmail

func (a *App) SendPasswordResetEmail(email, siteURL string, token *model.Token) error

SendPasswordResetEmail sends a password reset email.

func (*App) SendTestEmail

func (a *App) SendTestEmail(userEmail, siteURL string) error

SendTestEmail creates and sends a test email.

func (*App) SendVerifyEmailEmail

func (a *App) SendVerifyEmailEmail(email, siteURL string, token *model.Token) error

SendVerifyEmailEmail sends a verify-email email.

func (*App) Store

func (a *App) Store() store.Store

Store is an accessor for the app store.

func (*App) User

func (a *App) User() UserService

User is an accessor for the user service.

type Config

type Config struct {
	// the location to which a user might point their browser
	SiteURL string

	// the location to which the API should be called if is different than SiteURL
	APIURL string

	// Github OAuth configuration
	GithubOAuth GithubOAuth

	// email server related configuration
	Email email.Config

	// developer mode
	Dev bool
}

Config is the config used by the dashboard server app.

func NewConfig

func NewConfig() Config

NewConfig returns a new empty config.

type GithubOAuth

type GithubOAuth struct {
	ClientID      string
	ClientSecret  string
	EncryptionKey string
}

type HTMLTemplate

type HTMLTemplate struct {
	Template     *template.Template
	TemplateName string
	Props        map[string]interface{}
}

HTMLTemplate is a wrapper for specifying and rendering a given HTML template.

func (*HTMLTemplate) Render

func (t *HTMLTemplate) Render() (string, error)

Render renders the HTMLTemplate to a string.

func (*HTMLTemplate) RenderToWriter

func (t *HTMLTemplate) RenderToWriter(w io.Writer) error

RenderToWriter renders the template of the given name to the provided reader.

func (*HTMLTemplate) SetBaseProps

func (t *HTMLTemplate) SetBaseProps()

SetBaseProps sets common prop values for most email templates.

type UserService

type UserService interface {
	Create(user *model.User) (*model.User, error)
	Get(id string) (*model.User, error)
	GetByEmail(email string) (*model.User, error)
	Update(user *model.User) (*model.User, error)
	AuthenticateUserForLogin(email, password string) (*model.User, error)
	Login(w http.ResponseWriter, r *http.Request, user *model.User) error
	Logout(w http.ResponseWriter, r *http.Request, sessionID string)
	GetSession(tokenOrID string) (*model.Session, error)
	VerifyEmail(id, email string) error
	UnverifyEmail(id, email string) error
	HasAdminPermission(id string) (bool, error)
}

func NewUserService

func NewUserService(logger logrus.FieldLogger, store store.Store) UserService

Jump to

Keyboard shortcuts

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