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: 'authentication', | |
initialize: function(container, application) { | |
Ember.SimpleAuth.setup(container, application); | |
} | |
}); |
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: 'authentication', | |
initialize: function(container, application) { | |
Ember.SimpleAuth.setup(application); | |
} | |
}); |
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.route('login'); | |
this.route('logout'); | |
}); |
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.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin); | |
App.LogoutRoute = Ember.Route.extend(Ember.SimpleAuth.LogoutRouteMixin); |
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
<form {{action login on='submit'}}> | |
<label for="identification">Login</label> | |
{{view Ember.TextField id='identification' valueBinding='identification' placeholder='Enter Login'}} | |
<label for="password">Password</label> | |
{{view Ember.TextField id='password' type='password' valueBinding='password' placeholder='Enter Password'}} | |
<button type="submit">Login</button> | |
</form> |
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.ProtectedRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin); |
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.$.ajaxPrefilter(function(options, originalOptions, jqXHR) { | |
if (!jqXHR.crossDomain) { | |
jqXHR.setRequestHeader('X-AUTHENTICATION-TOKEN', App.Session.get('authToken')); | |
} | |
}); |
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({ | |
redirectToLogin: function(transition) { | |
App.Session.set('attemptedTransition', transition); | |
this.transitionTo('session.new'); | |
}, | |
beforeModel: function(transition) { | |
if (!App.Session.get('authToken')) { | |
this.redirectToLogin(transition); | |
} |
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.SessionDestroyRoute = Ember.Route.extend({ | |
renderTemplate: function(controller, model) { | |
controller.logout(); | |
} | |
}); |
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.SessionDestroyController = Ember.Controller.extend({ | |
logout: function() { | |
var self = this; | |
$.ajax({ | |
url: '/session', | |
type: 'DELETE' | |
}).always(function(response) { | |
App.Session.setProperties({ | |
authToken: '', | |
authAccountId: '' |