feat(invite): new user invites are now also added to correct org after sign up is completed, #2353

This commit is contained in:
Torkel Ödegaard 2015-08-11 10:45:03 +02:00
parent 74932e6311
commit 1ea0b5371a
3 changed files with 15 additions and 1 deletions

View File

@ -178,6 +178,17 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
Login: user.Login, Login: user.Login,
}) })
// add to org
addOrgUserCmd := m.AddOrgUserCommand{OrgId: invite.OrgId, UserId: user.Id, Role: invite.Role}
if err := bus.Dispatch(&addOrgUserCmd); err != nil {
return ApiError(500, "Error while trying to create org user", err)
}
// set org to active
if err := bus.Dispatch(&m.SetUsingOrgCommand{OrgId: invite.OrgId, UserId: user.Id}); err != nil {
return ApiError(500, "Failed to set org as active", err)
}
// update temp user status // update temp user status
updateTmpUserCmd := m.UpdateTempUserStatusCommand{Code: invite.Code, Status: m.TmpUserCompleted} updateTmpUserCmd := m.UpdateTempUserStatusCommand{Code: invite.Code, Status: m.TmpUserCompleted}
if err := bus.Dispatch(&updateTmpUserCmd); err != nil { if err := bus.Dispatch(&updateTmpUserCmd); err != nil {

View File

@ -75,9 +75,10 @@ type GetTempUserByCodeQuery struct {
type TempUserDTO struct { type TempUserDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
OrgId int64 `json:"orgId"`
Name string `json:"name"` Name string `json:"name"`
Email string `json:"email"` Email string `json:"email"`
Role string `json:"role"` Role RoleType `json:"role"`
InvitedByLogin string `json:"invitedByLogin"` InvitedByLogin string `json:"invitedByLogin"`
InvitedByEmail string `json:"invitedByEmail"` InvitedByEmail string `json:"invitedByEmail"`
InvitedByName string `json:"invitedByName"` InvitedByName string `json:"invitedByName"`

View File

@ -52,6 +52,7 @@ func CreateTempUser(cmd *m.CreateTempUserCommand) error {
func GetTempUsersForOrg(query *m.GetTempUsersForOrgQuery) error { func GetTempUsersForOrg(query *m.GetTempUsersForOrgQuery) error {
var rawSql = `SELECT var rawSql = `SELECT
tu.id as id, tu.id as id,
tu.org_id as org_id,
tu.email as email, tu.email as email,
tu.name as name, tu.name as name,
tu.role as role, tu.role as role,
@ -76,6 +77,7 @@ func GetTempUsersForOrg(query *m.GetTempUsersForOrgQuery) error {
func GetTempUserByCode(query *m.GetTempUserByCodeQuery) error { func GetTempUserByCode(query *m.GetTempUserByCodeQuery) error {
var rawSql = `SELECT var rawSql = `SELECT
tu.id as id, tu.id as id,
tu.org_id as org_id,
tu.email as email, tu.email as email,
tu.name as name, tu.name as name,
tu.role as role, tu.role as role,