diff options
Diffstat (limited to 'app/controllers/app.go')
| -rw-r--r-- | app/controllers/app.go | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/app/controllers/app.go b/app/controllers/app.go deleted file mode 100644 index 87c8bd1..0000000 --- a/app/controllers/app.go +++ /dev/null @@ -1,78 +0,0 @@ -package controllers - -import "github.com/revel/revel" - -type App struct { - *revel.Controller -} - -func (c App) Index() revel.Result { - return c.Render() -} - -func (c App) Account() revel.Result { - return c.Render() -} - -func (c App) PrintLogin() revel.Result { - return c.Render() -} - -func (c App) Login(login, password string) revel.Result { - - c.Validation.Required(login).Message("Please provide a user name or email.") - c.Validation.Required(password).Message("Please enter a password.") - - if c.Validation.HasErrors() { - c.Validation.Keep() - c.FlashParams() - return c.Redirect(App.PrintLogin) - } - - u := User{} - db.Where("name = ?", login).Or("email = ?", login).Find(&u) - - c.Validation.Required(VerifyPassword(u.Password, password)).Message("User / Password combination did not matched.") - if c.Validation.HasErrors() { - c.Validation.Keep() - c.FlashParams() - return c.Redirect(App.PrintLogin) - } - - c.Session["login"] = "true" - c.Session["uid"] = string(u.Id) - - return c.Redirect(App.Account) -} - -func (c App) Register(email, confirmEmail, user, password, confirmPassword string) revel.Result { - c.Validation.Required(email).Message("Please provide a mail adress.") - c.Validation.Required(email == confirmEmail).Message("The mail adresses do not match.") - c.Validation.Required(user).Message("Please provide a user name.") - - if password != "" { - c.Validation.Required(password == confirmPassword).Message("Passwords do not match.") - } - - if c.Validation.HasErrors() { - c.Validation.Keep() - c.FlashParams() - return c.Redirect(App.PrintLogin) - } - - p, _ := HashPassword(password) - - user := User{ - Name: user, - Email: email, - Password: p, - } - - db.NewRecord(u) - db.Create(&u) - db.Save(&u) - - c.Flash.Success("Registration completed.") - - return c.Redirect(App.Account) -} |
