Skip to content

Instantly share code, notes, and snippets.

Avatar
🙈
🙉🙊

Marco Otte-Witte marcoow

🙈
🙉🙊
View GitHub Profile
View adapters.application.js
import Adapter from "ember-data/adapters/json-api";
export default Adapter.extend();
View controllers.application.js
import Ember from 'ember';
const { computed, Object: O } = Ember;
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
things: [
O.create({ value: 1 }),
O.create({ value: 2 }),
O.create({ value: 3 })
View keybase.md

Keybase proof

I hereby claim:

  • I am marcoow on github.
  • I am marcoow (https://keybase.io/marcoow) on keybase.
  • I have a public key whose fingerprint is 0EC5 B0E0 3A33 1DA0 6B2F 23F8 48F6 64E9 7230 3B2D

To claim this, I am signing this object:

View setup.js
Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
Ember.SimpleAuth.setup(container, application, {
authorizerFactory: 'authorizer:oauth2-bearer'
});
}
});
View session_account.js
Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
// customize the session so that it allows access to the account object
Ember.SimpleAuth.Session.reopen({
account: function() {
var accountId = this.get('account_id');
if (!Ember.isEmpty(accountId)) {
return container.lookup('store:main').find('account', accountId);
}
View ember-simple-auth.js
Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
Ember.SimpleAuth.setup(container, application);
}
});
App.Router.map(function() {
this.route('login');
this.route('protected');
View protected.js
App.Router.map(function() {
this.route('protected');
});
App.ProtectedRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin);
View login.html
<form {{action authenticate on='submit'}}>
<label for="identification">Login</label>
{{input id='identification' placeholder='Enter Login' value=identification}}
<label for="password">Password</label>
{{input id='password' placeholder='Enter Password' type='password' value=password}}
<button type="submit">Login</button>
</form>
View buttons.html
{{#if session.isAuthenticated}}
<a {{ action 'invalidateSession' }}>Logout</a>
{{else}}
<a {{ action 'authenticateSession' }}>Login</a>
{{/if}}
View application_route.js
App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin);