grafana/pkg/api/signup.go

30 lines
601 B
Go
Raw Normal View History

package api
import (
2015-02-05 03:37:13 -06:00
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/middleware"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
)
// POST /api/user/signup
2015-01-21 02:52:40 -06:00
func SignUp(c *middleware.Context, cmd m.CreateUserCommand) {
2015-01-29 08:46:54 -06:00
if setting.DisableUserSignUp {
c.JsonApiErr(401, "User signup is disabled", nil)
return
}
cmd.Login = cmd.Email
2015-01-08 02:00:00 -06:00
if err := bus.Dispatch(&cmd); err != nil {
c.JsonApiErr(500, "failed to create user", err)
return
}
2015-01-21 02:52:40 -06:00
user := cmd.Result
loginUserWithUser(&user, c)
c.JsonOK("User created and logged in")
}