@@ -15,6 +15,7 @@ import (
1515 "gopkg.in/authboss.v0/internal/render"
1616)
1717
18+ // Storer and FormValue constants
1819const (
1920 StoreConfirmToken = "confirm_token"
2021 StoreConfirmed = "confirmed"
@@ -43,16 +44,18 @@ func init() {
4344 authboss .RegisterModule ("confirm" , & Confirm {})
4445}
4546
47+ // Confirm module
4648type Confirm struct {
4749 emailHTMLTemplates render.Templates
4850 emailTextTemplates render.Templates
4951}
5052
53+ // Initialize the module
5154func (c * Confirm ) Initialize () (err error ) {
5255 var ok bool
5356 storer , ok := authboss .Cfg .Storer .(ConfirmStorer )
5457 if storer == nil || ! ok {
55- return errors .New ("confirm: Need a ConfirmStorer. " )
58+ return errors .New ("confirm: Need a ConfirmStorer" )
5659 }
5760
5861 c .emailHTMLTemplates , err = render .LoadTemplates (authboss .Cfg .LayoutHTMLEmail , authboss .Cfg .ViewsPath , tplConfirmHTML )
@@ -64,27 +67,29 @@ func (c *Confirm) Initialize() (err error) {
6467 return err
6568 }
6669
67- authboss .Cfg .Callbacks .Before (authboss .EventGet , c .BeforeGet )
68- authboss .Cfg .Callbacks .Before (authboss .EventAuth , c .BeforeGet )
69- authboss .Cfg .Callbacks .After (authboss .EventRegister , c .AfterRegister )
70+ authboss .Cfg .Callbacks .Before (authboss .EventGet , c .beforeGet )
71+ authboss .Cfg .Callbacks .Before (authboss .EventAuth , c .beforeGet )
72+ authboss .Cfg .Callbacks .After (authboss .EventRegister , c .afterRegister )
7073
7174 return nil
7275}
7376
77+ // Routes for the module
7478func (c * Confirm ) Routes () authboss.RouteTable {
7579 return authboss.RouteTable {
7680 "/confirm" : c .confirmHandler ,
7781 }
7882}
7983
84+ // Storage requirements
8085func (c * Confirm ) Storage () authboss.StorageOptions {
8186 return authboss.StorageOptions {
8287 StoreConfirmToken : authboss .String ,
8388 StoreConfirmed : authboss .Bool ,
8489 }
8590}
8691
87- func (c * Confirm ) BeforeGet (ctx * authboss.Context ) (authboss.Interrupt , error ) {
92+ func (c * Confirm ) beforeGet (ctx * authboss.Context ) (authboss.Interrupt , error ) {
8893 if confirmed , err := ctx .User .BoolErr (StoreConfirmed ); err != nil {
8994 return authboss .InterruptNone , err
9095 } else if ! confirmed {
@@ -95,7 +100,7 @@ func (c *Confirm) BeforeGet(ctx *authboss.Context) (authboss.Interrupt, error) {
95100}
96101
97102// AfterRegister ensures the account is not activated.
98- func (c * Confirm ) AfterRegister (ctx * authboss.Context ) error {
103+ func (c * Confirm ) afterRegister (ctx * authboss.Context ) error {
99104 if ctx .User == nil {
100105 return errUserMissing
101106 }
0 commit comments