func (c User) SaveUser(user models.User, verifyPassword string) revel.Result {
	var activeUser *models.User
	if c.RenderArgs["user"] == nil {
		c.Flash.Error("You must log in first")
		return c.Redirect(routes.App.Index())
	}
	activeUser = c.RenderArgs["user"].(*models.User)
	if !activeUser.IsAdmin {
		c.Flash.Error("You do not have permissions for this page")
		return c.Redirect(routes.App.Index())
	}
	err := c.saveUser(user, verifyPassword)
	if err != nil {
		c.Flash.Error("Unable to save user", err.Error())
		return c.Redirect(routes.User.Register())
	}
	c.Flash.Success("Created user " + user.Username)
	return c.Redirect(routes.Admin.Index())
}
Create and save the new user
package controllers
import (
	"github.com/JustinJudd/CAGo/app/models"
	"github.com/JustinJudd/CAGo/app/routes"
	"code.google.com/p/go.crypto/bcrypt"
	"github.com/robfig/revel"
)
type User struct {
	App
}
func (c App) getUser(username string) *models.User {
	users, err := c.Txn.Select(models.User{}, `select * from User where Username = ?`, username)
	if err != nil {
		panic(err)
	}
	if len(users) == 0 {
		return nil
	}
	return users[0].(*models.User)
}
func (c App) getUserFromId(userId int) *models.User {
	users, err := c.Txn.Select(models.User{}, `select * from User where Id = ?`, userId)
	if err != nil {
		panic(err)
	}
	if len(users) == 0 {
		return nil
	}
	return users[0].(*models.User)
}
func (c App) connected() *models.User {
	if c.RenderArgs["user"] != nil {
		return c.RenderArgs["user"].(*models.User)
	}
	if username, ok := c.Session["user"]; ok {
		return c.getUser(username)
	}
	return nil
}
func (c App) AddUser() revel.Result {
	if user := c.connected(); user != nil {
		c.RenderArgs["user"] = user
	}
	return nil
}
func (c User) Index() revel.Result {
	if c.Session["user"] == "" {
		c.Flash.Error("Not Logged In")
		return c.Redirect(routes.App.Index())
	}
	return c.Render()
}
func (c User) Login(username, password string) revel.Result {
	if _, ok := c.RenderArgs["user"]; ok {
		return c.Redirect(routes.App.Index())
	}
	user := c.getUser(username)
	if user != nil {
		err := bcrypt.CompareHashAndPassword(user.HashedPassword, []byte(password))
		if err == nil {
			c.Session["user"] = username
			c.Flash.Success("Welcome, " + username)
			return c.Redirect(routes.App.Index())
		}
	}
	c.Flash.Out["username"] = username
	c.Flash.Error("Login failed")
	return c.Redirect(routes.App.Index())
}
func (c User) Register() revel.Result {
	return c.Render()
}
func (c User) Create() revel.Result {
	var user *models.User
	if c.RenderArgs["user"] == nil {
		c.Flash.Error("You must log in first")
		return c.Redirect(routes.App.Index())
	}
	user = c.RenderArgs["user"].(*models.User)
	if !user.IsAdmin {
		c.Flash.Error("You do not have permissions for this page")
		return c.Redirect(routes.App.Index())
	}
	breadcrumbs := make([]BreadCrumb, 0)
	breadcrumbs = append(breadcrumbs, BreadCrumb{Name: "Home", Url: routes.App.Index()})
	breadcrumbs = append(breadcrumbs, BreadCrumb{Name: "Admin", Url: routes.Admin.Index()})
	breadcrumbs = append(breadcrumbs, BreadCrumb{Name: "Manage Users", Url: routes.Admin.Users()})
	breadcrumbs = append(breadcrumbs, BreadCrumb{Name: "Create User", Url: routes.User.Create(), Active: true})
	return c.Render(breadcrumbs)
}