Skip to content

Commit 79464ca

Browse files
committed
First tutorial release
1 parent f9f787d commit 79464ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+696
-3
lines changed

.bowerrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"directory": "bower_components",
3+
"analytics": false
4+
}

.editorconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
indent_style = space
14+
indent_size = 2
15+
16+
[*.js]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[*.hbs]
21+
indent_style = space
22+
indent_size = 2
23+
24+
[*.css]
25+
indent_style = space
26+
indent_size = 2
27+
28+
[*.html]
29+
indent_style = space
30+
indent_size = 2
31+
32+
[*.md]
33+
trim_trailing_whitespace = false

.ember-cli

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
/**
3+
Ember CLI sends analytics information by default. The data is completely
4+
anonymous, but there are times when you might want to disable this behavior.
5+
6+
Setting `disableAnalytics` to true will prevent any data from being sent.
7+
*/
8+
"disableAnalytics": false
9+
}

.jshintrc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"predef": [
3+
"document",
4+
"window",
5+
"-Promise"
6+
],
7+
"browser" : true,
8+
"boss" : true,
9+
"curly": true,
10+
"debug": false,
11+
"devel": true,
12+
"eqeqeq": true,
13+
"evil": true,
14+
"forin": false,
15+
"immed": false,
16+
"laxbreak": false,
17+
"newcap": true,
18+
"noarg": true,
19+
"noempty": false,
20+
"nonew": false,
21+
"nomen": false,
22+
"onevar": false,
23+
"plusplus": false,
24+
"regexp": false,
25+
"undef": true,
26+
"sub": true,
27+
"strict": false,
28+
"white": false,
29+
"eqnull": true,
30+
"esnext": true,
31+
"unused": true
32+
}

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
language: node_js
3+
4+
sudo: false
5+
6+
cache:
7+
directories:
8+
- node_modules
9+
10+
install:
11+
- npm install -g bower
12+
- npm install
13+
- bower install
14+
15+
script:
16+
- npm test

Brocfile.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* global require, module */
2+
3+
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
4+
5+
var app = new EmberApp();
6+
7+
// Use `app.import` to add additional libraries to the generated
8+
// output files.
9+
//
10+
// If you need to use different assets in different
11+
// environments, specify an object as the first parameter. That
12+
// object's keys should be the environment name and the values
13+
// should be the asset to use in that environment.
14+
//
15+
// If the library that you are including contains AMD or ES6
16+
// modules that you would like to import into your application
17+
// please specify an object with the list of modules as keys
18+
// along with the exports of each module as its value.
19+
20+
module.exports = app.toTree();

README.md

Lines changed: 122 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,123 @@
1-
EmberAuthTutorial
2-
=================
1+
# Ember-auth-tutorial
32

4-
A quick Ember.js Authorization tutorial using Ember-CLI, Ember-Simple-Auth, and Torii
3+
This is a tutorial outlining how to create an [Ember.js](http://emberjs.com) app with authorization using
4+
5+
- [Ember-CLI](http://www.ember-cli.com/)
6+
- [Ember-Simple-Auth](https://github.com/simplabs/ember-simple-auth)
7+
- [Torii](https://github.com/Vestorly/torii)
8+
9+
10+
# Tutorial
11+
12+
This assumes you have git, node, bower, and ember-cli installed
13+
14+
### Create a new ember app
15+
16+
`ember init` or `ember new` see the ember-cli docs for more info
17+
18+
19+
20+
### Get dependencies
21+
22+
```
23+
npm install --save-dev torii ember-cli-simple-auth-torii
24+
ember generate ember-cli-simple-auth-torii
25+
```
26+
27+
28+
29+
### Basic App setup
30+
31+
```
32+
ember g route application
33+
ember g route protected
34+
ember g route login
35+
ember g controller login
36+
```
37+
38+
39+
40+
### Add Mixins
41+
42+
```
43+
//--- /app/routes/application.js
44+
import Ember from 'ember';
45+
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
46+
47+
export default Ember.Route.extend(ApplicationRouteMixin);
48+
```
49+
50+
```
51+
//--- /app/routes/protected.js
52+
import Ember from 'ember';
53+
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
54+
55+
export default Ember.Route.extend(AuthenticatedRouteMixin);
56+
```
57+
58+
59+
60+
### Add Login Actions and setup controller
61+
62+
You could add more torii providers, see the [documentation](https://github.com/Vestorly/torii) for more info
63+
64+
```
65+
//--- /app/controllers/login.js
66+
import Ember from 'ember';
67+
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';
68+
69+
export default Ember.Controller.extend(LoginControllerMixin, {
70+
authenticator: 'authenticator:torii'
71+
});
72+
```
73+
74+
```
75+
//--- /app/routes/login.js
76+
import Ember from 'ember';
77+
78+
export default Ember.Route.extend({
79+
actions: {
80+
googleLogin: function() {
81+
this.get('session').authenticate('simple-auth-authenticator:torii', 'google-oauth2');
82+
return;
83+
}
84+
}
85+
});
86+
```
87+
88+
89+
90+
### Update your templates
91+
92+
See [example](app/templates)
93+
94+
95+
96+
### Get google setup
97+
98+
This is likely analgous to other torii providers, I have only used google
99+
- client_id from [google](https://console.developers.google.com/project) under API & auth > credentials
100+
- update your authorized origins (ex. http://localhost:4200/)
101+
- update the redirect URI (ex. http://localhost:4200)
102+
103+
104+
105+
### Update environment.js
106+
107+
```
108+
//--- config/environment.js
109+
ENV['torii'] = {
110+
providers: {
111+
'google-oauth2': {
112+
apiKey: 'client_id from google',
113+
scope: 'profile',
114+
redirectUri: 'http://localhost:4200'
115+
}
116+
}
117+
};
118+
```
119+
120+
121+
122+
### Test & Enjoy
123+
run `ember server` and try it out!

app/app.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Ember from 'ember';
2+
import Resolver from 'ember/resolver';
3+
import loadInitializers from 'ember/load-initializers';
4+
import config from './config/environment';
5+
6+
Ember.MODEL_FACTORY_INJECTIONS = true;
7+
8+
var App = Ember.Application.extend({
9+
modulePrefix: config.modulePrefix,
10+
podModulePrefix: config.podModulePrefix,
11+
Resolver: Resolver
12+
});
13+
14+
loadInitializers(App, config.modulePrefix);
15+
16+
export default App;

app/components/.gitkeep

Whitespace-only changes.

app/controllers/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)