简体   繁体   中英

Ember-simple-auth change cookie on the fly

I have an Ember application and I use ember-simple-auth for authentication. I want to change the cookie stored, that is related with the authentication, on the fly. The reason is a feature of impersonating another user. I have used

Ember.$.cookie

but it returns "undefined". How could I change the cookie, after I have signed in as user 'X', in order to impersonate user 'Y'?

You shouldn't write to the cookie directly as that's maintained by ESA and its contents might change in future versions. Instead you can write to the session data by writing to the session service's data attribute, eg this.get('session').set('data.user_id', '<some-user-id>') .

It might not be a great idea to identify the current user by some value stored in the session as your users could set that value as well then…

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