When creating user (not signup) autoconfirm email
This commit is contained in:
+3
-1
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user