Skip to content

Commit 5bdcddd

Browse files
committed
Rename internal/render to internal/response
1 parent db1eb3a commit 5bdcddd

17 files changed

Lines changed: 418 additions & 364 deletions

auth/auth.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"golang.org/x/crypto/bcrypt"
1010
"gopkg.in/authboss.v0"
11-
"gopkg.in/authboss.v0/internal/render"
11+
"gopkg.in/authboss.v0/internal/response"
1212
)
1313

1414
const (
@@ -24,7 +24,7 @@ func init() {
2424

2525
// Auth module
2626
type Auth struct {
27-
templates render.Templates
27+
templates response.Templates
2828
}
2929

3030
// Initialize module
@@ -41,7 +41,7 @@ func (a *Auth) Initialize() (err error) {
4141
return errors.New("auth: XSRFMaker must be defined")
4242
}
4343

44-
a.templates, err = render.LoadTemplates(authboss.Cfg.Layout, authboss.Cfg.ViewsPath, tplLogin)
44+
a.templates, err = response.LoadTemplates(authboss.Cfg.Layout, authboss.Cfg.ViewsPath, tplLogin)
4545
if err != nil {
4646
return err
4747
}
@@ -71,7 +71,7 @@ func (a *Auth) loginHandlerFunc(ctx *authboss.Context, w http.ResponseWriter, r
7171
if _, ok := ctx.SessionStorer.Get(authboss.SessionKey); ok {
7272
if halfAuthed, ok := ctx.SessionStorer.Get(authboss.SessionHalfAuthKey); !ok || halfAuthed == "false" {
7373
//http.Redirect(w, r, authboss.Cfg.AuthLoginOKPath, http.StatusFound, true)
74-
render.Redirect(ctx, w, r, authboss.Cfg.AuthLoginOKPath, "", "", true)
74+
response.Redirect(ctx, w, r, authboss.Cfg.AuthLoginOKPath, "", "", true)
7575
return nil
7676
}
7777
}
@@ -115,7 +115,7 @@ func (a *Auth) loginHandlerFunc(ctx *authboss.Context, w http.ResponseWriter, r
115115
case authboss.InterruptAccountNotConfirmed:
116116
reason = "Your account has not been confirmed."
117117
}
118-
render.Redirect(ctx, w, r, authboss.Cfg.AuthLoginFailPath, "", reason, false)
118+
response.Redirect(ctx, w, r, authboss.Cfg.AuthLoginFailPath, "", reason, false)
119119
return nil
120120
}
121121

@@ -125,7 +125,7 @@ func (a *Auth) loginHandlerFunc(ctx *authboss.Context, w http.ResponseWriter, r
125125
if err := authboss.Cfg.Callbacks.FireAfter(authboss.EventAuth, ctx); err != nil {
126126
return err
127127
}
128-
render.Redirect(ctx, w, r, authboss.Cfg.AuthLoginOKPath, "", "", true)
128+
response.Redirect(ctx, w, r, authboss.Cfg.AuthLoginOKPath, "", "", true)
129129
default:
130130
w.WriteHeader(http.StatusMethodNotAllowed)
131131
}
@@ -157,7 +157,7 @@ func (a *Auth) logoutHandlerFunc(ctx *authboss.Context, w http.ResponseWriter, r
157157
ctx.CookieStorer.Del(authboss.CookieRemember)
158158
ctx.SessionStorer.Del(authboss.SessionLastAction)
159159

160-
render.Redirect(ctx, w, r, authboss.Cfg.AuthLogoutOKPath, "", "", true)
160+
response.Redirect(ctx, w, r, authboss.Cfg.AuthLogoutOKPath, "You have logged out", "", true)
161161
default:
162162
w.WriteHeader(http.StatusMethodNotAllowed)
163163
}

confirm/confirm.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"path"
1313

1414
"gopkg.in/authboss.v0"
15-
"gopkg.in/authboss.v0/internal/render"
15+
"gopkg.in/authboss.v0/internal/response"
1616
)
1717

1818
// Storer and FormValue constants
@@ -46,8 +46,8 @@ func init() {
4646

4747
// Confirm module
4848
type Confirm struct {
49-
emailHTMLTemplates render.Templates
50-
emailTextTemplates render.Templates
49+
emailHTMLTemplates response.Templates
50+
emailTextTemplates response.Templates
5151
}
5252

5353
// Initialize the module
@@ -58,11 +58,11 @@ func (c *Confirm) Initialize() (err error) {
5858
return errors.New("confirm: Need a ConfirmStorer")
5959
}
6060

61-
c.emailHTMLTemplates, err = render.LoadTemplates(authboss.Cfg.LayoutHTMLEmail, authboss.Cfg.ViewsPath, tplConfirmHTML)
61+
c.emailHTMLTemplates, err = response.LoadTemplates(authboss.Cfg.LayoutHTMLEmail, authboss.Cfg.ViewsPath, tplConfirmHTML)
6262
if err != nil {
6363
return err
6464
}
65-
c.emailTextTemplates, err = render.LoadTemplates(authboss.Cfg.LayoutTextEmail, authboss.Cfg.ViewsPath, tplConfirmText)
65+
c.emailTextTemplates, err = response.LoadTemplates(authboss.Cfg.LayoutTextEmail, authboss.Cfg.ViewsPath, tplConfirmText)
6666
if err != nil {
6767
return err
6868
}
@@ -144,7 +144,7 @@ func (c *Confirm) confirmEmail(to, token string) {
144144
Subject: authboss.Cfg.EmailSubjectPrefix + "Confirm New Account",
145145
}
146146

147-
err := render.RenderEmail(email, c.emailHTMLTemplates, tplConfirmHTML, c.emailTextTemplates, tplConfirmText, url)
147+
err := response.Email(email, c.emailHTMLTemplates, tplConfirmHTML, c.emailTextTemplates, tplConfirmText, url)
148148
if err != nil {
149149
fmt.Fprintf(authboss.Cfg.LogWriter, "confirm: Failed to send e-mail: %v", err)
150150
}
@@ -188,7 +188,7 @@ func (c *Confirm) confirmHandler(ctx *authboss.Context, w http.ResponseWriter, r
188188
}
189189

190190
ctx.SessionStorer.Put(authboss.SessionKey, key)
191-
render.Redirect(ctx, w, r, authboss.Cfg.RegisterOKPath, "You have successfully confirmed your account.", "", true)
191+
response.Redirect(ctx, w, r, authboss.Cfg.RegisterOKPath, "You have successfully confirmed your account.", "", true)
192192

193193
return nil
194194
}

0 commit comments

Comments
 (0)