简体   繁体   中英

Ember Uncaught Error: Attempted to handle event `didSetProperty`

I am getting this error and it seems to be when I destroy the session on my "auth" logic. I have read everything I can find and it seems to be something to do with the values of the object that is being destroyed, but I've tried everything I have found and no luck. If anyone could point me in the right direction to a solution I would greatly appreciate it.

Error

Uncaught Error: Attempted to handle event didSetProperty on while in state root.deleted.saved. Called with {name: email, oldValue: undefined, originalValue: undefined, value: test@test.com}.

Controller

App.ApplicationController = Ember.ObjectController.extend
  actions:
    signOut: ->
      @get('model').destroyRecord().then =>
        $.removeCookie 'apiKey'
        @set 'model', @store.createRecord 'session'
        @transitionToRoute 'sign-in'
      , ->
        @transitionToRoute 'sign-in'

Route

App.ApplicationRoute = Ember.Route.extend
  model: ->
    if !$.cookie 'apiKey'
      @store.createRecord 'session'
    else
      @store.find('session', 'current').then (session)->
        session

Session Model

App.Session = DS.Model.extend
  access_token: DS.attr()
  email: DS.attr()
  password: DS.attr()
  isLoggedIn: Ember.computed.notEmpty 'access_token'
  user: DS.belongsTo 'user', embedded: 'always'

App.SessionSerializer = DS.ActiveModelSerializer.extend DS.EmbeddedRecordsMixin,
  attrs: user: embedded: 'always'

This is a bit late, sorry.

When the promise to destroy the model is resolved, something is being set on the model - session record in this case. Please note the @get('model').destroyRecord() command is followed by the @set 'model' command.

That is why the error message has while in state root.deleted.saved .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM