This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.SessionNewController = Ember.Controller.extend({ | |
login: function() { | |
var self = this; | |
var data = this.getProperties('loginOrEmail', 'password'); | |
if (!Ember.isEmpty(data.loginOrEmail) && !Ember.isEmpty(data.password)) { | |
var postData = { session: { login_or_email: data.loginOrEmail, password: data.password } }; | |
$.post('/session', postData).done(function(response) { | |
var sessionData = (response.session || {}) | |
App.Session.setProperties({ | |
authToken: sessionData.auth_token, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Router.map(function() { | |
this.resource('session', function() { | |
this.route('new'); | |
this.route('destroy'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
def current_user | |
@current_user ||= begin | |
auth_token = request.env['HTTP_X_AUTHENTICATION_TOKEN'] | |
Account.find_by(auth_token: auth_token) if !!auth_token | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.AuthenticatedRESTAdapter = DS.RESTAdapter.extend({ | |
ajax: function(url, type, hash) { | |
hash = hash || {}; | |
hash.headers = hash.headers || {}; | |
hash.headers['X-AUTHENTICATION-TOKEN'] = App.Store.authToken; | |
return this._super(url, type, hash); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.Application.initializer({ | |
name: 'session', | |
initialize: function(container, application) { | |
App.Session = Ember.Object.extend({ | |
init: function() { | |
this._super(); | |
this.set('authToken', $.cookie('auth_token')); | |
this.set('authAccountId', $.cookie('auth_account')); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= 1.7.2 | |
* fixed Simplabs::Excellent::Checks::Rails::CustomInitializeMethodCheck | |
* fixed Simplabs::Excellent::Checks::MethodNameCheck so it allows method names that exist in Ruby itself | |
* fixed Simplabs::Excellent::Checks::GlobalVariableCheck so it doesn't report false positives for rescue bodies | |
* made the parser more forgiving/stable in some situations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.AuthManager = Ember.Object.extend({ | |
init: function() { | |
this._super(); | |
var authToken = $.cookie('auth_token'); | |
var authAccountId = $.cookie('auth_account'); | |
if (!Ember.isEmpty(authToken) && !Ember.isEmpty(authAccountId)) { | |
this.authenticate(authToken, authAccountId); | |
} | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Session = DS.Model.extend({ | |
authToken: DS.attr('string'), | |
account: DS.belongsTo('App.Account') | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthenticatedController < ApplicationController | |
ensure_authenticated_user | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.AuthenticatedRoute = Ember.Route.extend({ | |
enter: function() { | |
if (!Ember.isEmpty(App.Auth.get('authToken')) && !Ember.isEmpty(App.Auth.get('accountId'))) { | |
this.transitionTo('sessions.new'); | |
} | |
} | |
}); |