Commit aa89416b by Torkel Ödegaard

fix(invite): fixes to org invite stuff, #2630

parent e93fba20
......@@ -158,6 +158,7 @@ func CompleteInvite(c *middleware.Context, completeInvite dtos.CompleteInviteFor
Name: completeInvite.Name,
Login: completeInvite.Username,
Password: completeInvite.Password,
SkipOrgSetup: true,
}
if err := bus.Dispatch(&cmd); err != nil {
......
......@@ -65,6 +65,7 @@ func SignUpStep2(c *middleware.Context, form dtos.SignUpStep2Form) Response {
OrgName: form.OrgName,
}
// verify email
if setting.VerifyEmailEnabled {
if ok, rsp := verifyUserSignUpEmail(form.Email, form.Code); !ok {
return rsp
......@@ -72,11 +73,13 @@ func SignUpStep2(c *middleware.Context, form dtos.SignUpStep2Form) Response {
createUserCmd.EmailVerified = true
}
// check if user exists
existing := m.GetUserByLoginQuery{LoginOrEmail: form.Email}
if err := bus.Dispatch(&existing); err == nil {
return ApiError(401, "User with same email address already exists", nil)
}
// dispatch create command
if err := bus.Dispatch(&createUserCmd); err != nil {
return ApiError(500, "Failed to create user", err)
}
......
......@@ -52,6 +52,7 @@ type CreateUserCommand struct {
Password string
EmailVerified bool
IsAdmin bool
SkipOrgSetup bool
Result User
}
......
......@@ -153,7 +153,7 @@ func signUpCompletedHandler(evt *events.SignUpCompleted) error {
return sendEmailCommandHandler(&m.SendEmailCommand{
To: []string{evt.Email},
Template: tmplSignUpStarted,
Template: tmplWelcomeOnSignUp,
Data: map[string]interface{}{
"Name": evt.Name,
},
......
......@@ -30,6 +30,10 @@ func init() {
}
func getOrgIdForNewUser(cmd *m.CreateUserCommand, sess *session) (int64, error) {
if cmd.SkipOrgSetup {
return -1, nil
}
var org m.Org
if setting.AutoAssignOrg {
......@@ -103,7 +107,18 @@ func CreateUser(cmd *m.CreateUserCommand) error {
return err
}
sess.publishAfterCommit(&events.UserCreated{
Timestamp: user.Created,
Id: user.Id,
Name: user.Name,
Login: user.Login,
Email: user.Email,
})
cmd.Result = user
// create org user link
if !cmd.SkipOrgSetup {
orgUser := m.OrgUser{
OrgId: orgId,
UserId: user.Id,
......@@ -119,16 +134,8 @@ func CreateUser(cmd *m.CreateUserCommand) error {
if _, err = sess.Insert(&orgUser); err != nil {
return err
}
}
sess.publishAfterCommit(&events.UserCreated{
Timestamp: user.Created,
Id: user.Id,
Name: user.Name,
Login: user.Login,
Email: user.Email,
})
cmd.Result = user
return nil
})
}
......
......@@ -200,7 +200,7 @@
Multi format
</li>
<li ng-show="current.multi">
<select class="input-small tight-form-input last" ng-model="current.multiFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'regex values']"></select>
<select class="input-medium tight-form-input last" ng-model="current.multiFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'regex values']"></select>
</li>
</ul>
<div class="clearfix"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment