Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(signup): began work on new / alternate signup flow that includes…
… email verification, #2353
- Loading branch information
Showing
11 changed files
with
57 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,48 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/grafana/grafana/pkg/api/dtos" | ||
"github.com/grafana/grafana/pkg/bus" | ||
"github.com/grafana/grafana/pkg/events" | ||
"github.com/grafana/grafana/pkg/metrics" | ||
"github.com/grafana/grafana/pkg/middleware" | ||
m "github.com/grafana/grafana/pkg/models" | ||
"github.com/grafana/grafana/pkg/setting" | ||
"github.com/grafana/grafana/pkg/util" | ||
) | ||
|
||
// POST /api/user/signup | ||
func SignUp(c *middleware.Context, cmd m.CreateUserCommand) Response { | ||
func SignUp(c *middleware.Context, form dtos.SignUpForm) Response { | ||
if !setting.AllowUserSignUp { | ||
return ApiError(401, "User signup is disabled", nil) | ||
} | ||
|
||
cmd.Login = cmd.Email | ||
existing := m.GetUserByLoginQuery{LoginOrEmail: form.Email} | ||
if err := bus.Dispatch(&existing); err == nil { | ||
return ApiError(401, "User with same email address already exists", nil) | ||
} | ||
|
||
cmd := m.CreateTempUserCommand{} | ||
cmd.OrgId = -1 | ||
cmd.Email = form.Email | ||
cmd.Status = m.TmpUserSignUpStarted | ||
cmd.InvitedByUserId = c.UserId | ||
cmd.Code = util.GetRandomString(10) | ||
cmd.RemoteAddr = c.Req.RemoteAddr | ||
|
||
if err := bus.Dispatch(&cmd); err != nil { | ||
return ApiError(500, "failed to create user", err) | ||
return ApiError(500, "Failed to create signup", err) | ||
} | ||
|
||
user := cmd.Result | ||
|
||
bus.Publish(&events.UserSignedUp{ | ||
Id: user.Id, | ||
Name: user.Name, | ||
Email: user.Email, | ||
Login: user.Login, | ||
}) | ||
// user := cmd.Resu | ||
|
||
loginUserWithUser(&user, c) | ||
bus.Publish(&events.UserSignedUp{Email: form.Email}) | ||
|
||
metrics.M_Api_User_SignUp.Inc(1) | ||
// | ||
// loginUserWithUser(&user, c) | ||
// | ||
// | ||
|
||
metrics.M_Api_User_SignUpStarted.Inc(1) | ||
return ApiSuccess("User created and logged in") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
<div class="container"> | ||
<div class="login-page-background"> | ||
</div> | ||
|
||
<div class="login-box"> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters