Skip to content

Instantly share code, notes, and snippets.

View mockra's full-sized avatar

David Ratajczak mockra

View GitHub Profile
var gulp = require('gulp');
var concat = require('gulp-concat');
var stylus = require('gulp-stylus');
gulp.task('styles', function() {
gulp.src('./bower_components/bootstrap/dist/css/bootstrap.css')
.pipe(concat('vendor.css'))
.pipe(gulp.dest('./public'))
gulp.src('./assets/**/*.styl')
class SessionsController < ApplicationController
def create
user = User.find_by_email params[:username]
if user && user.authenticate(params[:password])
render json: { access_token: user.access_token }
else
render json: {}, status: 401
end
end
end
<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>
App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin);
App.Router.map(function() {
this.route('login');
});
App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin);
App.Router.map(function() {
this.resource('todos', { path: '/' }, function() {
this.route('active');
this.route('completed');
});
});
Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
Ember.SimpleAuth.setup(container, application);
}
});
DS.RESTAdapter.reopen({
host: 'https://api.example.com'
// OR
url: 'https://api.example.com'
});
App.TodosRoute = Ember.Route.extend({
model: function () {
return this.store.find('todo');
}
});
App.TodosIndexRoute = Ember.Route.extend({
model: function () {
return this.modelFor('todos');
}
App.TodosController = Ember.ArrayController.extend({
actions: {
createTodo: function () {
// Get the todo title set by the "New Todo" text field
var title = this.get('newTitle');
if (!title.trim()) { return; }
// Create the new Todo model
var todo = this.store.createRecord( App.Todo, {
title: title,