aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auth/controller.go3
-rw-r--r--main.go2
-rw-r--r--user/user.go2
-rw-r--r--user/validators.go9
4 files changed, 10 insertions, 6 deletions
diff --git a/auth/controller.go b/auth/controller.go
index 1e6f7fe..71cdc6a 100644
--- a/auth/controller.go
+++ b/auth/controller.go
@@ -25,7 +25,6 @@ import (
"vidhukant.com/openbills/user"
"net/http"
"time"
- "fmt"
)
var (
@@ -72,8 +71,6 @@ func handleSignIn (ctx *gin.Context) {
var req LoginReq
ctx.Bind(&req)
- fmt.Println(req)
-
var err error
var u user.User
diff --git a/main.go b/main.go
index 76e2831..f750a4b 100644
--- a/main.go
+++ b/main.go
@@ -37,7 +37,7 @@ import (
"log"
)
-const OPENBILLS_VERSION = "v0.0.6"
+const OPENBILLS_VERSION = "v0.0.7"
func init() {
if viper.GetBool("production_mode") {
diff --git a/user/user.go b/user/user.go
index ee36e95..132acb6 100644
--- a/user/user.go
+++ b/user/user.go
@@ -40,7 +40,7 @@ type User struct {
gorm.Model
Username string
Email string
- Password string
+ Password string `json:"-"`
IsVerified bool
}
diff --git a/user/validators.go b/user/validators.go
index 88239c6..647da06 100644
--- a/user/validators.go
+++ b/user/validators.go
@@ -19,6 +19,7 @@ package user
import (
"strings"
+ "net/mail"
e "errors"
"github.com/spf13/viper"
"vidhukant.com/openbills/errors"
@@ -73,9 +74,15 @@ func (u *User) validate() error {
u.IsVerified = false
// TODO: validate username length and stuff
- // TODO: validate if email is valid
var err error
+
+ // validate email
+ _, err = mail.ParseAddress(u.Email)
+ if err != nil {
+ return errors.ErrInvalidEmail
+ }
+
for _, i := range [][]string{{"username", u.Username}, {"email", u.Email}} {
err = validateUserField(i[0], i[1])
if err != nil {