3
0

When creating user (not signup) autoconfirm email

This commit is contained in:
Denis Arh
2020-04-08 17:02:28 +02:00
parent 23bf0c52c7
commit 337361e1c6
3 changed files with 11 additions and 3 deletions
+3 -1
View File
@@ -74,7 +74,9 @@ func (ctrl User) Create(ctx context.Context, r *request.UserCreate) (interface{}
Handle: r.Handle,
Kind: r.Kind,
EmailConfirmed: r.HasEmailConfirmed() && r.EmailConfirmed,
// consider email confirmed
// when creating user like this
EmailConfirmed: true,
}
return ctrl.user.With(ctx).Create(user)
+1 -1
View File
@@ -709,7 +709,7 @@ func (svc auth) ValidatePasswordResetToken(token string) (user *types.User, err
}
if !user.EmailConfirmed {
// Confirm email while reseting password...
// Confirm email while resetting password...
user.EmailConfirmed = true
svc.users.Update(user)
}
+7 -1
View File
@@ -253,14 +253,20 @@ func TestUserCreate(t *testing.T) {
h := newHelper(t)
h.allow(types.SystemPermissionResource, "user.create")
email := h.randEmail()
h.apiInit().
Post("/users/").
FormData("email", h.randEmail()).
FormData("email", email).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
u, err := h.repoUser().FindByEmail(email)
h.a.NoError(err)
h.a.NotNil(u)
h.a.True(u.EmailConfirmed)
}
func TestUserUpdateForbidden(t *testing.T) {