Skip to content

Changing any property on User extended model changes the emailVerified property to false #3063

Closed

Description

@qaiser110

Bug or feature request

  • Bug
  • Feature request

Issue Description

I've I've recently migrated to Loopback 3. I'm Postgresql database. One of my tests is failing with a strange behaviour. I've raised this issue on Stackoverflow as well.

I have a Member model that extends the User model. Whenever I change any property on my Member model, the emailVerified changes from true to false

Member.findById(memberId, function (err, user) {
  console.log(user.emailVerified);   // true

  user.updateAttribute('username', 'abc', function (err, result) {
    console.log(result.emailVerified);   // false
  })
});

I've also tried with updateAttributes but the results are the same.

I found that in user model code, emailChanged is returning true because ctx.data.email is undefined. Changing it to first check if it exists does solve my problem.

var emailChanged = ctx.hookState.originalUserData.some(function(data) {
  return ctx.data.email && data.email != ctx.data.email;
});

Additional information

Node v 7,
LoopBack v 3.0

Activity

  1. mackwan84 commented on Jan 3, 2017

    @mackwan84

    +1 I am facing the same problem after update to 3.0.

  2. hussainak commented on Jan 3, 2017

    @hussainak

    +1

  3. notbrain commented on Jan 3, 2017

    @notbrain

    +1 in 2.36.2

    Our password reset is now broken because of this too. emailVerified set to 0.

    Just tried to upgrade from our pinned 2.29.1 version of loopback to the latest 2.x version. Was pinned because of a previous regression wrt PUT/PATCH endpoint verbs. Trying to get back up to latest.

    Tried to explicitly set emailVerified = 1 in our custom reset function we created, but no dice (must be being reset in some "after" middleware in User? We extend with Person).

    Loopback 2.36.2 is not backwards compatible with 2.29.1. Sigh.

  4. lleopardi commented on Jan 4, 2017

    @lleopardi

    +1

  5. lschricke commented on Jan 4, 2017

    @lschricke
    Contributor

    Same issue here.

  6. davidcheung commented on Jan 4, 2017

    @davidcheung
    Contributor

    once this lands it should fix
    #3053

  7. davidcheung commented on Jan 10, 2017

    @davidcheung
    Contributor

    this bug should be fixed in #3053 or in (2.x) #3072, please ping me in this thread if issue persists to reopen. Closing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions