Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push to production #557

Merged
merged 15 commits into from Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

![Code Corps Ember Logo](https://d3pgew4wbk2vb1.cloudfront.net/images/github/code-corps-ember.png)

[![Code Climate](https://codeclimate.com/github/code-corps/code-corps-ember/badges/gpa.svg)](https://codeclimate.com/github/code-corps/code-corps-ember) [![CircleCI](https://circleci.com/gh/code-corps/code-corps-ember.svg?style=svg)](https://circleci.com/gh/code-corps/code-corps-ember) [![Dependency Status](https://david-dm.org/code-corps/code-corps-ember.svg)](https://david-dm.org/code-corps/code-corps-ember) [![devDependency Status](https://david-dm.org/code-corps/code-corps-ember/dev-status.svg)](https://david-dm.org/code-corps/code-corps-ember#info=devDependencies) [![Inline docs](http://inch-ci.org/github/code-corps/code-corps-ember.svg?branch=develop&style=shields)](http://inch-ci.org/github/code-corps/code-corps-ember) [![Slack Status](http://slack.codecorps.org/badge.svg)](http://slack.codecorps.org)
[![CircleCI](https://circleci.com/gh/code-corps/code-corps-ember.svg?style=shield)](https://circleci.com/gh/code-corps/code-corps-ember) [![devDependency Status](https://david-dm.org/code-corps/code-corps-ember/dev-status.svg)](https://david-dm.org/code-corps/code-corps-ember#info=devDependencies) [![Inline docs](http://inch-ci.org/github/code-corps/code-corps-ember.svg?branch=develop&style=shields)](http://inch-ci.org/github/code-corps/code-corps-ember) [![Slack Status](http://slack.codecorps.org/badge.svg)](http://slack.codecorps.org)

This Code Corps Ember application powers the front-end website for the Code Corps platform, consuming our Elixir JSON API.

Expand Down
1 change: 1 addition & 0 deletions app/styles/components/login-form.scss
@@ -1,4 +1,5 @@
.login-form {
@include span-columns(5);
@include shift(3.5);
padding-top: 10vh;
}
1 change: 1 addition & 0 deletions app/styles/components/signup-form.scss
@@ -1,6 +1,7 @@
.signup-form {
@include span-columns(5);
@include shift(3.5);
padding-top: 10vh;

input[type="submit"] {
width: 100%;
Expand Down
11 changes: 11 additions & 0 deletions app/styles/main.scss
Expand Up @@ -23,6 +23,17 @@ html, body {
height: 100%;
}

.flexbox-container {
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 100vh;
}

.flexbox-spacer {
flex: auto;
}

p {
font-size: $body-font-size-normal;
}
Expand Down
17 changes: 10 additions & 7 deletions app/templates/application.hbs
@@ -1,12 +1,15 @@
{{title "Code Corps"}}

{{#drag-zone}}
{{navigation-menu}}
{{flash-messages}}
<div class="main container {{codeTheme.className}}">
{{outlet}}
<div class="flexbox-container">
{{navigation-menu}}
{{flash-messages}}
<div class="main container {{codeTheme.className}}">
{{outlet}}
</div>
<div class="flexbox-spacer"></div>
{{#unless isOnboarding}}
{{site-footer}}
{{/unless}}
</div>
{{#unless isOnboarding}}
{{site-footer}}
{{/unless}}
{{/drag-zone}}
14 changes: 4 additions & 10 deletions config/environment.js
Expand Up @@ -84,7 +84,6 @@ module.exports = function(environment) {
// ENV.APP.LOG_VIEW_LOOKUPS = true;

ENV.API_BASE_URL = 'http://api.lvh.me:49235';
ENV.SERVER_TOKEN_ENDPOINT = 'http://api.lvh.me:49235/login';
ENV.WEB_BASE_URL = 'http://localhost:4200';

ENV.sentry.development = true;
Expand All @@ -93,10 +92,6 @@ module.exports = function(environment) {
enabled: false
};

ENV['ember-simple-auth-token'] = {
serverTokenEndpoint: '/login',
}

ENV.contentSecurityPolicy = {
'default-src': "'none'",
'script-src': [
Expand Down Expand Up @@ -131,15 +126,13 @@ module.exports = function(environment) {

if (environment === 'remote-development') {
ENV.API_BASE_URL = 'http://api.pbqrpbecf-qri.org';
ENV.SERVER_TOKEN_ENDPOINT = 'http://api.pbqrpbecf-qri.org/login';
ENV.WEB_BASE_URL = 'http://www.pbqrpbecf-qri.org';

ENV.sentry.development = true;
}

if (environment === 'staging') {
ENV.API_BASE_URL = 'http://api.pbqrpbecf.org';
ENV.SERVER_TOKEN_ENDPOINT = 'http://api.pbqrpbecf.org/login';
ENV.WEB_BASE_URL = 'http://www.pbqrpbecf.org';

ENV.sentry.dsn = 'https://c494e4250972401e84b74526fdf1182b@app.getsentry.com/82742';
Expand All @@ -157,7 +150,6 @@ module.exports = function(environment) {
ENV.APP.rootElement = '#ember-testing';

ENV.API_BASE_URL = '';
ENV.SERVER_TOKEN_ENDPOINT = '/login';
ENV.WEB_BASE_URL = '';

ENV.sentry.development = true;
Expand All @@ -173,12 +165,14 @@ module.exports = function(environment) {

if (environment === 'production') {
ENV.API_BASE_URL = 'https://api.codecorps.org';
ENV.SERVER_TOKEN_ENDPOINT = 'https://api.codecorps.org/login';
ENV.WEB_BASE_URL = 'http://www.codecorps.org';
}

ENV['ember-simple-auth-token'] = {
serverTokenEndpoint: ENV.SERVER_TOKEN_ENDPOINT,
serverTokenEndpoint: ENV.API_BASE_URL + '/token',
serverTokenRefreshEndpoint: ENV.API_BASE_URL + '/token/refresh',
refreshLeeway: 3000, // 5 minutes before expiry
timeFactor: 1000,
};

return ENV;
Expand Down
180 changes: 84 additions & 96 deletions mirage/config.js
Expand Up @@ -77,7 +77,6 @@ export default function() {
// GET /categories
this.get('/categories');


////////////////////////
// Comment user mentions
////////////////////////
Expand All @@ -92,7 +91,6 @@ export default function() {
return schema.commentUserMentions.where({ commentId: commentId });
});


///////////
// Comments
///////////
Expand Down Expand Up @@ -123,35 +121,6 @@ export default function() {
return comment;
});


////////
// Login
////////

// POST /login
this.post('/login', (db, request) => {
let json = JSON.parse(request.requestBody);

if(json.username === "josh@coderly.com" && json.password === "password") {
return {
// token encoded at https://jwt.io/
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ"
};
} else {
return new Mirage.Response(400, {}, {
errors: [
{
id: "INVALID_GRANT",
title: "Invalid grant",
detail: "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
status: 401
}
]
});
}
});


///////////////////////////
// Organization memberships
///////////////////////////
Expand All @@ -171,7 +140,6 @@ export default function() {
// PATCH /organization-memberships/:id
this.patch('/organization-memberships/:id');


////////////////
// Organizations
////////////////
Expand All @@ -180,65 +148,6 @@ export default function() {

this.get('/organizations/:id');


/////////////////////
// Task user mentions
/////////////////////

// GET /task-user-mentions
this.get('/task-user-mentions', (schema, request) => {
let taskId = request.queryParams.task_id;
let task = schema.tasks.find(taskId);

generateTaskMentions(schema, task);

return schema.taskUserMentions.where({ taskId: taskId });
});


////////
// Tasks
////////

// POST /tasks
this.post('/tasks', function(schema) {
let attrs = this.normalizedRequestAttrs();

// the API takes takes markdown and renders body
attrs.body = `<p>${attrs.markdown}</p>`;

// the API sets task number as an auto-incrementing value, scoped to project,
// so we need to simulate that here
attrs.number = schema.projects.find(attrs.projectId).tasks.models.length + 1;

return schema.create('task', attrs);
});

// PATCH /tasks/:id
this.patch('/tasks/:id', function(schema) {
let attrs = this.normalizedRequestAttrs();

// the API takes takes markdown and renders body
attrs.body = `<p>${attrs.markdown}</p>`;

let task = schema.tasks.find(attrs.id);
task.attrs = attrs;

task.taskUserMentions.models.forEach((mention) => mention.destroy());
task.save();

return task;
});

// GET tasks/:number/comments
this.get('/tasks/:taskId/comments', function(schema, request) {
let taskId = request.params.taskId;
let task = schema.tasks.find(taskId);

return task.comments;
});


///////////
// Previews
///////////
Expand Down Expand Up @@ -422,11 +331,94 @@ export default function() {
// GET /skills/:id
this.get('/skills/:id');

/////////////////////
// Task user mentions
/////////////////////

// GET /task-user-mentions
this.get('/task-user-mentions', (schema, request) => {
let taskId = request.queryParams.task_id;
let task = schema.tasks.find(taskId);

generateTaskMentions(schema, task);

return schema.taskUserMentions.where({ taskId: taskId });
});

////////
// Users
// Tasks
////////

// POST /tasks
this.post('/tasks', function(schema) {
let attrs = this.normalizedRequestAttrs();

// the API takes takes markdown and renders body
attrs.body = `<p>${attrs.markdown}</p>`;

// the API sets task number as an auto-incrementing value, scoped to project,
// so we need to simulate that here
attrs.number = schema.projects.find(attrs.projectId).tasks.models.length + 1;

return schema.create('task', attrs);
});

// PATCH /tasks/:id
this.patch('/tasks/:id', function(schema) {
let attrs = this.normalizedRequestAttrs();

// the API takes takes markdown and renders body
attrs.body = `<p>${attrs.markdown}</p>`;

let task = schema.tasks.find(attrs.id);
task.attrs = attrs;

task.taskUserMentions.models.forEach((mention) => mention.destroy());
task.save();

return task;
});

// GET tasks/:number/comments
this.get('/tasks/:taskId/comments', function(schema, request) {
let taskId = request.params.taskId;
let task = schema.tasks.find(taskId);

return task.comments;
});

////////
// Token
////////

// POST /token
this.post('/token', (db, request) => {
console.log(request);
let json = JSON.parse(request.requestBody);

if(json.username === "volunteers@codecorps.org" && json.password === "password") {
return {
// token encoded at https://jwt.io/
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ"
};
} else {
let errorDetail = "Your password doesn't match the email " + json.username + ".";
return new Mirage.Response(401, {}, {
errors: [
{
id: "UNAUTHORIZED",
title: "401 Unauthorized",
detail: errorDetail,
status: 401
}
]
});
}
});

////////
// Users
////////

this.get('/users', { coalesce: true });

Expand Down Expand Up @@ -467,13 +459,11 @@ export default function() {
return { available: true, valid: true };
});


// GET /users/username_available
this.get('/users/username_available', () => {
return { available: true, valid: true };
});


//////////////////
// User categories
//////////////////
Expand All @@ -490,7 +480,6 @@ export default function() {
// DELETE /user-categories/:id
this.delete('/user-categories/:id');


/////////////
// User roles
/////////////
Expand All @@ -501,7 +490,6 @@ export default function() {
// DELETE /user-roles
this.delete('/user-roles/:id');


//////////////
// User skills
//////////////
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -76,7 +76,7 @@
"ember-page-title": "3.0.9",
"ember-resolver": "^2.0.3",
"ember-simple-auth": "1.1.0",
"ember-simple-auth-token": "git@github.com:digia/ember-simple-auth-token.git",
"ember-simple-auth-token": "^1.1.1",
"ember-sinon": "0.5.1",
"ember-tether": "0.3.1",
"ember-tooltips": "2.0.1",
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/login-test.js
Expand Up @@ -34,7 +34,8 @@ test('Logging in', function(assert) {
});

test('Login failure', function(assert) {
const ERROR_TEXT = 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.';
// Mirage expects volunteers@codecorps.org as default email
const ERROR_TEXT = "Your password doesn't match the email volunteers@codecorps.org.";

assert.expect(2);

Expand Down