Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
rhinoman committed Mar 28, 2016
1 parent 22c40f3 commit de9320c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
31 changes: 20 additions & 11 deletions common/services/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,28 @@ func getErrorCode(err error) int {

//Writes and logs errors from the couchdb driver
func WriteError(err error, response *restful.Response) {
str := err.Error()
errStrings := strings.Split(str, ":")
statusCode := 0
var cErr error
if len(errStrings) > 1 {
statusCode, cErr = strconv.Atoi(errStrings[1])
}
if cErr != nil || statusCode == 0 {
statusCode = 500
var statusCode int
var reason string = "error"
//Is this a couchdb error?
cErr, ok := err.(*couchdb.Error)
if ok { // Yes!
statusCode = cErr.StatusCode
reason = cErr.Reason
} else { // No, try to parse :(
str := err.Error()
errStrings := strings.Split(str, ":")
statusCode := 0
var cErr error
if len(errStrings) > 1 {
statusCode, cErr = strconv.Atoi(errStrings[1])
reason = http.StatusText(statusCode)
}
if cErr != nil || statusCode == 0 {
statusCode = 500
}
}
//Write the error to the response
response.WriteErrorString(statusCode,
http.StatusText(statusCode))
response.WriteErrorString(statusCode, reason)
//Log the error
log.Printf("%v", err)
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/web_app/app/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ <h2 class="form-register-heading">Register</h2>
}
$("#registerForm").on("submit", function(event){
event.preventDefault();
var button = event.currentTarget;
$(button).attr("disabled", "disabled");
const userName = $("#inputUsername").val();
const password = $("#inputPassword").val();
const verifyPassword = $("#verifyPassword").val();
const email = $("#inputEmail").val();
if(password !== verifyPassword){
showError(["Password fields do not match"]);
$(button).removeAttr("disabled");
return;
}
const newUser = {
Expand All @@ -111,6 +114,7 @@ <h2 class="form-register-heading">Register</h2>
var errors = validateUser(newUser);
if(errors.length > 0){
showError(errors);
$(button).removeAttr("disabled");
} else {
$.ajax({
type: "POST",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
CC=gcc
export CC

VERSION=0.8.1-alpha
VERSION=0.9.0
ARCH=`uname -p`
OS=`uname`
BUILDNAME=wikifeat_${VERSION}.${OS}-${ARCH}
Expand Down
11 changes: 8 additions & 3 deletions users/user_service/user_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ package user_service
// Manager for User Records

import (
"errors"
"github.com/rhinoman/couchdb-go"
"github.com/rhinoman/wikifeat/common/config"
. "github.com/rhinoman/wikifeat/common/database"
Expand Down Expand Up @@ -669,15 +668,21 @@ func (um *UserManager) GetUserListForRole(pageNum int, numPerPage int,
func (um *UserManager) validateUser(user *User) error {
var err error
if len(user.UserName) < 3 || len(user.UserName) > 80 {
err = errors.New("Username invalid")
err = &couchdb.Error{
StatusCode: 400,
Reason: "Username invalid",
}
}
return err
}

//Validate Password
func (um *UserManager) validatePassword(password string) error {
if len(password) < config.Auth.MinPasswordLength {
return errors.New("Password too short")
return &couchdb.Error{
StatusCode: 400,
Reason: "Password too short",
}
} else {
return nil
}
Expand Down

0 comments on commit de9320c

Please sign in to comment.