// SignupUser creates and stores user information for the new user. Upon
// successful registration, the user is signed in and the new generated token
// is returned.
SignupUser creates and stores user information for the new user. Upon
successful registration, the user is signed in and the new generated token
is returned.
// SignupUser creates and stores user information for the new user . Upon // successful registration the user is signed in and the new generated token // is returned .
func (lm *LoginManager) SignupUser(login UserLogin, ctx *dispatch.Context) (err error) {
	existing := SavedUser{}
	err = lm.DB.Table("users").GetObject(login.Username, &existing)
	if err != nil && err != sql.ErrNoRows {
		return err
	}
	if existing.Username != "" {
		log.Println("User already exists")
		return errors.New("User already exists")
	}
	hashed, err := GetHash(login.Password)
	if err != nil {
		return err
	}
	err = lm.DB.Table("users").SetObject(login.Username, SavedUser{login.Username, hashed})
	if err != nil {
		return err
	}
	return lm.AuthenticateUser(login, ctx)
}
func ( lm * LoginManager ) SignupUser ( login UserLogin , ctx * dispatch . Context ) ( err error ) { existing := SavedUser { } err = lm . DB . Table ( " " ) . GetObject ( login . Username , & existing ) if err != nil && err != sql . ErrNoRows { return err } if existing . Username != " " { log . Println ( " " ) return errors . New ( " " ) } hashed , err := GetHash ( login . Password ) if err != nil { return err } err = lm . DB . Table ( " " ) . SetObject ( login . Username , SavedUser { login . Username , hashed } ) if err != nil { return err } return lm . AuthenticateUser ( login , ctx ) }
SignupUser creates and stores user information for the new user.
SignupUser creates and stores user information for the new user .