Sha256: 024d029f26ff085798dd877de0401970ea63b8273ac930b1f360624abe67c0da
Contents?: true
Size: 1.54 KB
Versions: 16
Compression:
Stored size: 1.54 KB
Contents
Dashboard.CustomAuthenticator = SimpleAuth.Authenticators.Devise.extend restore: (properties) -> new Ember.RSVP.Promise((resolve, reject) -> if not Ember.isEmpty(properties.access_token) resolve properties else reject() return ) authenticate: (credentials) -> _this = this new Ember.RSVP.Promise((resolve, reject) -> data = email: credentials.identification password: credentials.password _this.makeRequest(data).then ((response) -> Ember.run -> resolve response ), (xhr, status, error) -> Ember.run -> reject xhr.responseJSON or xhr.responseText ) Dashboard.CustomAuthorizer = SimpleAuth.Authorizers.Base.extend authorize: (jqXHR, requestOptions) -> accessToken = @get('session.access_token') if @get('session.isAuthenticated') and not Ember.isEmpty(accessToken) jqXHR.setRequestHeader 'Authorization', 'Token token=' + accessToken Ember.Application.initializer name: 'authentication' before: 'simple-auth' initialize: (container, application) -> container.register 'authenticator:custom', Dashboard.CustomAuthenticator container.register 'authorizer:custom', Dashboard.CustomAuthorizer SimpleAuth.Session.reopen currentUser: (-> userId = @get('user_id') if Ember.isEmpty(userId) && Ember.testing userId = 1 if !Ember.isEmpty(userId) Ember.run -> Dashboard.__container__.lookup('store:main').find('user', userId) ).property('user_id')
Version data entries
16 entries across 16 versions & 1 rubygems