Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registration doesn't work #3

Closed
kabukky opened this issue Jun 4, 2015 · 2 comments
Closed

Registration doesn't work #3

kabukky opened this issue Jun 4, 2015 · 2 comments

Comments

@kabukky
Copy link

kabukky commented Jun 4, 2015

Hey,
using http://localhost:8080/auth/register to register a new user doesn't seem to work. After the POST, there is no new user in the MemStorer, only the default one.
There is also no activity about a confirmation mail.
Since ab.Mailer = authboss.LogMailer(os.Stdout) is set, I was assuming to see at least something about it in the console.
Is there something to configure first?

Thanks
Kai

@kris-runzer
Copy link
Contributor

Hello!

Sorry for that; the issue is there was an error with the validation (it was looking for "username" instead of "email").

The default validators when you call authboss.New() are the following:

c.Policies = []Validator{
    Rules{
        FieldName:       "username",
        Required:        true,
        MinLength:       2,
        MaxLength:       4,
        AllowWhitespace: false,
    },
    Rules{
        FieldName:       "password",
        Required:        true,
        MinLength:       4,
        MaxLength:       8,
        AllowWhitespace: false,
    },
}

The default primaryID for authboss is "email', not "username". I've have pushed the fix to authboss to prevent this issue: 7cb7298

Alternatively you can override the validators in blog.go

ab.Mailer = authboss.LogMailer(os.Stdout)

// Set new policies
ab.Policies = []authboss.Validator{
    authboss.Rules{
        FieldName:       "email",
        Required:        true,
        AllowWhitespace: false,
    },
    authboss.Rules{
        FieldName:       "password",
        Required:        true,
        MinLength:       4,
        MaxLength:       8,
        AllowWhitespace: false,
    },
}

if err := ab.Init(); err != nil {
    log.Fatal(err)
}

@kabukky
Copy link
Author

kabukky commented Jun 4, 2015

Works like a charm now. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants