1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-09-16 09:06:20 +02:00

register: Context+Request separation ripple

This commit is contained in:
Aaron L
2015-08-02 13:02:31 -07:00
parent 15bbe59c7a
commit 8691f3bca9
2 changed files with 6 additions and 6 deletions

View File

@@ -85,7 +85,7 @@ func (reg *Register) registerPostHandler(ctx *authboss.Context, w http.ResponseW
key := r.FormValue(reg.PrimaryID)
password := r.FormValue(authboss.StorePassword)
validationErrs := ctx.Validate(req, reg.Policies, reg.ConfirmFields...)
validationErrs := authboss.Validate(r, reg.Policies, reg.ConfirmFields...)
if user, err := ctx.Storer.Get(key); err != nil && err != authboss.ErrUserNotFound {
return err
@@ -107,7 +107,7 @@ func (reg *Register) registerPostHandler(ctx *authboss.Context, w http.ResponseW
return reg.templates.Render(ctx, w, r, tplRegister, data)
}
attr, err := ctx.Attributes() // Attributes from overriden forms
attr, err := authboss.AttributesFromRequest(r) // Attributes from overriden forms
if err != nil {
return err
}
@@ -129,7 +129,7 @@ func (reg *Register) registerPostHandler(ctx *authboss.Context, w http.ResponseW
}
for _, f := range reg.PreserveFields {
data[f], _ = ctx.FirstFormValue(f)
data[f] = r.FormValue(f)
}
return reg.templates.Render(ctx, w, r, tplRegister, data)

View File

@@ -58,7 +58,7 @@ func TestRegisterGet(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest("GET", "/register", nil)
ctx, _ := reg.ContextFromRequest(r)
ctx := reg.NewContext()
ctx.SessionStorer = mocks.NewMockClientStorer()
if err := reg.registerHandler(ctx, w, r); err != nil {
@@ -93,7 +93,7 @@ func TestRegisterPostValidationErrs(t *testing.T) {
r, _ := http.NewRequest("POST", "/register", bytes.NewBufferString(vals.Encode()))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
ctx, _ := reg.ContextFromRequest(r)
ctx := reg.NewContext()
ctx.SessionStorer = mocks.NewMockClientStorer()
if err := reg.registerHandler(ctx, w, r); err != nil {
@@ -131,7 +131,7 @@ func TestRegisterPostSuccess(t *testing.T) {
r, _ := http.NewRequest("POST", "/register", bytes.NewBufferString(vals.Encode()))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
ctx, _ := reg.ContextFromRequest(r)
ctx := reg.NewContext()
ctx.SessionStorer = mocks.NewMockClientStorer()
if err := reg.registerHandler(ctx, w, r); err != nil {