feat(signup): progress on new sign up and email verification flow, #2353
This commit is contained in:
@@ -8,6 +8,7 @@ type SignUpStep2Form struct {
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Code string `json:"code"`
|
||||
OrgName string `json:"orgName"`
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func GetPendingOrgInvites(c *middleware.Context) Response {
|
||||
query := m.GetTempUsersForOrgQuery{OrgId: c.OrgId, Status: m.TmpUserInvitePending}
|
||||
query := m.GetTempUsersQuery{OrgId: c.OrgId, Status: m.TmpUserInvitePending}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
return ApiError(500, "Failed to get invites from db", err)
|
||||
@@ -172,10 +172,8 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
|
||||
user := cmd.Result
|
||||
|
||||
bus.Publish(&events.SignUpCompleted{
|
||||
Id: user.Id,
|
||||
Name: user.Name,
|
||||
Name: user.NameOrFallback(),
|
||||
Email: user.Email,
|
||||
Login: user.Login,
|
||||
})
|
||||
|
||||
// add to org
|
||||
|
||||
+28
-4
@@ -34,15 +34,11 @@ func SignUp(c *middleware.Context, form dtos.SignUpForm) Response {
|
||||
return ApiError(500, "Failed to create signup", err)
|
||||
}
|
||||
|
||||
// user := cmd.Resu
|
||||
|
||||
bus.Publish(&events.SignUpStarted{
|
||||
Email: form.Email,
|
||||
Code: cmd.Code,
|
||||
})
|
||||
|
||||
// loginUserWithUser(&user, c)
|
||||
|
||||
metrics.M_Api_User_SignUpStarted.Inc(1)
|
||||
|
||||
return Json(200, util.DynMap{"status": "SignUpCreated"})
|
||||
@@ -72,5 +68,33 @@ func SignUpStep2(c *middleware.Context, form dtos.SignUpStep2Form) Response {
|
||||
return ApiError(401, "User with same email address already exists", nil)
|
||||
}
|
||||
|
||||
// create user
|
||||
createUserCmd := m.CreateUserCommand{
|
||||
Email: tempUser.Email,
|
||||
Login: form.Username,
|
||||
Name: form.Name,
|
||||
Password: form.Password,
|
||||
OrgName: form.OrgName,
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&createUserCmd); err != nil {
|
||||
return ApiError(500, "Failed to create user", err)
|
||||
}
|
||||
|
||||
user := createUserCmd.Result
|
||||
|
||||
bus.Publish(&events.SignUpCompleted{
|
||||
Email: user.Email,
|
||||
Name: user.NameOrFallback(),
|
||||
})
|
||||
|
||||
// check for pending invites
|
||||
invitesQuery := m.GetTempUsersQuery{Email: tempUser.Email, Status: m.TmpUserInvitePending}
|
||||
if err := bus.Dispatch(&invitesQuery); err != nil {
|
||||
return ApiError(500, "Failed to query database for invites", err)
|
||||
}
|
||||
|
||||
loginUserWithUser(&user, c)
|
||||
metrics.M_Api_User_SignUpCompleted.Inc(1)
|
||||
return Json(200, util.DynMap{"status": "SignUpCreated"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user