summaryrefslogtreecommitdiff
path: root/app/controllers/app.go
diff options
context:
space:
mode:
authorHorus_Arch2015-02-15 17:59:13 +0100
committerHorus_Arch2015-02-15 17:59:13 +0100
commit26f781239bfcda867f19262becee3b9687a7c79d (patch)
tree04a439594815ce1b37a1a73303eee4ac7a5be487 /app/controllers/app.go
parenta69bf1307d20a395b0eca9ffae06f57a659dabf1 (diff)
downloadfreemail-26f781239bfcda867f19262becee3b9687a7c79d.tar.gz
Crashs on startup with error message 'Cannot start transaction.'
Diffstat (limited to 'app/controllers/app.go')
-rw-r--r--app/controllers/app.go51
1 files changed, 47 insertions, 4 deletions
diff --git a/app/controllers/app.go b/app/controllers/app.go
index 754deee..2b8945c 100644
--- a/app/controllers/app.go
+++ b/app/controllers/app.go
@@ -1,6 +1,10 @@
package controllers
-import "github.com/revel/revel"
+import (
+ _ "github.com/jinzhu/gorm"
+ _ "github.com/mattn/go-sqlite3"
+ "github.com/revel/revel"
+)
type App struct {
//*revel.Controller
@@ -11,10 +15,49 @@ func (c App) Index() revel.Result {
return c.Render()
}
-func (c App) Register() revel.Result {
- return c.Render()
+func (c App) DoRegister(name, email, confirmEmail, password, confirmPassword string) revel.Result {
+ c.Validation.Required(name).Message("Please provide a user name.")
+ c.Validation.Required(email).Message("Please provide a mail adress.")
+ c.Validation.Required(email == confirmEmail).Message("Mail adresses do not match.")
+ c.Validation.Required(password).Message("Please provide a password.")
+ c.Validation.Required(password == confirmPassword).Message("Passwords do not match.")
+
+ if c.Validation.HasErrors() {
+ c.Validation.Keep()
+ c.FlashParams()
+ return c.Redirect(App.Register)
+ }
+
+ hash := HashPassword(password)
+ revel.INFO.Printf("%s \n", hash)
+ user := User{Name: name, Email: email, Password: hash}
+
+ //c.Validation.Required(c.Db.NewRecord(user)).Message("User name already used.")
+ /*
+ if !c.Db.NewRecord(user) {
+ revel.ERROR.Println("User name already in use.")
+ }
+ */
+
+ revel.INFO.Printf("%s", c.Gdb)
+ c.Gdb.Debug().NewRecord(user)
+ c.Gdb.Debug().Save(&user)
+ //c.Db.Debug().NewRecord(user)
+ //c.Db.Debug().Save(&user)
+ //c.Db.Create(&user)
+
+ /*
+ if c.Validation.HasErrors() {
+ c.Validation.Keep()
+ c.FlashParams()
+ return c.Redirect(App.Register)
+ }
+ */
+
+ //return c.Render()
+ return c.Redirect(App.Register)
}
-func (c App) DoRegister() revel.Result {
+func (c App) Register() revel.Result {
return c.Render()
}