new_account_controller

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EmailStep = 2
View Source
const MaxUsernameLength = 20
View Source
const MinUsernameLength = 4
View Source
const PasswordConfirmationStep = 4
View Source
const PasswordEntropy = 40
View Source
const PasswordStep = 3
View Source
const UsernameRegex = `^[a-zA-Z0-9_]+$`
View Source
const UsernameStep = 1

Variables

View Source
var AfterCreateCallback = func(sessId string, entityId string) error {
	return login_controller.Login(sessId, entityId)
}
View Source
var Controller = controller{}
View Source
var PasswordValidator = func(password string) error {
	e := passwordvalidator.GetEntropy(password)

	if e < PasswordEntropy {

		return fmt.Errorf("That isn't a very secure password. Try something stronger.")
	}

	return nil
}
View Source
var UsernameValidator = func(username string) error {
	r, err := regexp.Compile(UsernameRegex)

	if err != nil {
		panic(err)
	}

	if len(username) < MinUsernameLength {

		return fmt.Errorf(
			"'%s' is not a valid username. It must be at least %d characters long.",
			username,
			MinUsernameLength,
		)
	}

	if len(username) >= MaxUsernameLength {

		return fmt.Errorf(
			"'%s' is not a valid username. It must be at most %d characters long.",
			username,
			MaxUsernameLength,
		)
	}

	if !r.MatchString(username) {
		return fmt.Errorf(
			"'%s' is not a valid username. It must contain only alpha-numeric characters, dashes (-) or underscores (_)",
			username,
		)
	}

	return nil
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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