@Mihir_K wrote:
I am using below gems for implementing session and role functionalities in my App. ember-rails (0.18.3) devise (3.5.1) rolify (4.0.0) authority (3.0.0) rails (4.1.16) ember-source (~> 1.6.1) Ember - 1.8.0
Problem: I can handle the sessions and roles accurately in one tab. However, if I open the app in another window or tab, my session/role functionalities fail in the original tab. I can see all the buttons and fields as a user role which should be visible to the admin role only. This problem is resolved when I click the refresh button on the original tab, however the other tabs fail in this situation.
This is a code snippet in my upload.js.hbs.hamlbars.erb file
%li = hb 'if session.isuser' do = hb 'link-to "file_uploads"' do %i.fa.fa-lg.fa-upload File Upload
This is a code snippet in my simple_auth.js.coffee file
MyInventoryApp.CustomAuthenticator = Ember.SimpleAuth.Authenticators.Base.extend( authenticate: (credentials) -> _this = @ return new Ember.RSVP.Promise((resolve, reject) -> data = {} return Ember.$.ajax({ url: '/api/v1/sessions', type: 'GET', data: data, dataType: 'json', beforeSend: (xhr, settings) -> xhr.setRequestHeader('Accept', settings.accepts.json) }).then( (response) -> roles = (r.name for r in response.user.roles) Ember.run( -> resolve ( uid: response.user.uid roles: roles isadmin: roles.contains('admin') isuser: roles.contains('user') ) ) , (xhr, status, error) -> Ember.run( -> reject(xhr.responseJSON || xhr.responseText) ) ) ) restore: (data) -> return new Ember.RSVP.Promise( (resolve, reject) -> if !Ember.isEmpty(data.uid) resolve(data) else reject() ) )
Posts: 1
Participants: 1