Skip to content

Commit c15fa7f

Browse files
committed
modernising quick start
1 parent 2404c0a commit c15fa7f

5 files changed

Lines changed: 47 additions & 91 deletions

File tree

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,56 @@
1-
---
2-
title: Configure your app
3-
---
1+
After successfully creating your Authmaker instance, it is time to create your
2+
app and configure it to use your new Authmaker Instance.
43

5-
After successfully creating your Authmaker instance, configure your existing Ember application to work with Authmaker.
4+
## Create your app
65

7-
#### Install addons
8-
9-
Authmaker works with [ember-simple-auth](https://ember-simple-auth.com/) to allow easy implementation of authentication and authorization in your app. From your Ember application directory, install ember-simple-auth and then authmaker-simple-auth:
6+
The quickest way to create your new application is to use the following npm init command:
107

118
```bash
12-
$ ember install ember-simple-auth
13-
$ ember install authmaker-ember-simple-auth
9+
npm init ember-app your-amazing-app
1410
```
1511

16-
#### Add Authmaker config
12+
This will create a new application for you in the folder `your-amazing-app`. You can make sure that it has initialised correctly by navigating to that app and starting it:
1713

18-
Open `config/environment.js` and include the configuration details provided by Authmaker when you created your instance. These will be unique to your project. (Make sure to use the _local_ configuration while in development.)
14+
```bash
15+
cd your-amazing-app
16+
npm start
17+
```
1918

20-
```javascript {data-filename=config/environment.js}
19+
You should be prompted to visit http://localhost:4200 which should look something like this when you visit it:
2120

22-
...
21+
![Ember Dummy App](/images/dummy-app.png)
2322

24-
if (environment === 'development') {
25-
// this object will be *UNIQUE* for your instance
26-
ENV.authmaker = {
27-
domainUrl: "https://my-app-name.authmaker.com",
28-
redirectUri: "http://localhost:4200/login",
29-
clientId: "yourClientId"
30-
};
31-
}
23+
Next we need to install the Authmaker addon.
3224

33-
...
34-
```
25+
## Installing Authmaker Simple Auth
3526

36-
#### Add ApplicationRouteMixin
27+
To get you started as quickly as possible we provide an Ember Addon that provides a lot of the functionality you would need. It is built to extend [ember-simple-auth](https://ember-simple-auth.com/) to allow easy implementation of authentication and authorization in your app.
3728

38-
Generate an application route if you do not already have one:
29+
From your Ember application directory, install [authmaker-ember-simple-auth](https://github.com/Authmaker/authmaker-ember-simple-auth) as follows:
3930

4031
```bash
41-
$ ember g route application
32+
ember install authmaker-ember-simple-auth
4233
```
4334

44-
Include the `ApplicationRouteMixin` that ember-simple-auth provides, as shown below:
45-
46-
```javascript {data-filename=app/routes/application.js}
35+
This will create a bunch of files in your application for you and update your environment config with example config that you will need to update before the Addon will start working.
4736

48-
import Ember from 'ember';
49-
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
37+
### Update Authmaker config
5038

51-
export default Ember.Route.extend(ApplicationRouteMixin, {
52-
});
53-
```
54-
55-
#### Add DataAdapterMixin
39+
If you open `config/environment.js` you will see that there are sections that will look something like this:
5640

57-
Next, generate an application adapter if you do not already have one:
5841

59-
```bash
60-
$ ember g adapter application
42+
```javascript {data-filename=config/environment.js}
43+
if (environment === 'development') {
44+
ENV.authmaker = {
45+
domainUrl: 'REPLACE_ME',
46+
redirectUri: 'REPLACE_ME',
47+
clientId: 'REPLACE_ME'
48+
};
49+
}
6150
```
6251

63-
In order to automatically include authorization headers on all outgoing requests to the server, we need to include the `DataAdapterMixin` provided by ember-simple-auth in our application adapter. Add the following to `app/adapters/application.js`:
64-
65-
```javascript {data-filename=app/adapters/application.js}
52+
You will need to replace these example configurations with the real config for your Authmaker application. To get the real configuration you should [login to your Authmaker dashboard](https://app.authmaker.com/instances) and click the button marked "Local Ember Config":
6653

67-
import DS from 'ember-data';
68-
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
54+
![Example Authmaker Instance](/images/instance.png)
6955

70-
export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
71-
authorizer: 'authorizer:application',
72-
});
73-
```
56+
When you click the button there will be a pop up with your specific config for your Authmaker app and you should replace the example config in the `development` section of your `environment.js` file to reflect this specific config.

guides/implement-login/login.md

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
1-
---
2-
title: Create login route
3-
---
1+
Now that we have our application created and the Authmaker addon installed we can create a login button
42

5-
Authmaker uses a dedicated login route to redirect users to a secure login and signup page for your app.
6-
7-
#### Add AuthmakerLoginRoute
8-
9-
Generate a route called **'login'** and add the `AuthmakerLoginRoute` mixin and our Authmaker configuration from `config/environment.js`.
10-
11-
```bash
12-
$ ember g route login
13-
```
14-
15-
```javascript {data-filename=app/routes/login.js}
16-
17-
import Ember from 'ember';
18-
import AuthmakerLoginRoute from 'authmaker-ember-simple-auth/mixins/login-route';
19-
import Config from 'my-blog/config/environment';
20-
21-
export default Ember.Route.extend(AuthmakerLoginRoute, {
22-
config: Config.authmaker,
23-
});
24-
```
25-
26-
This route is used solely by Authmaker to connect your application with Authmaker's login and signup tools. You will not need to add any template, controller, or route logic aside from the configuration shown above.
27-
28-
#### Add login/logout actions
3+
## Add login/logout actions
294

305
Next, generate a controller for the application route:
316

@@ -36,34 +11,32 @@ $ ember g controller application
3611
In this controller, add the actions **'login'** and **'logout'** as shown below:
3712

3813
```javascript {data-filename=app/controllers/application.js}
14+
import Controller from '@ember/controller';
15+
import { inject as service } from '@ember/service';
3916

40-
import Ember from 'ember';
41-
import Config from 'my-blog/config/environment';
42-
43-
const { inject: { service } } = Ember;
44-
45-
export default Ember.Controller.extend({
17+
export default Controller.extend({
4618
session: service(),
4719

4820
actions: {
49-
login() {
50-
return this.get('session').authenticate('authenticator:authmaker', Config.authmaker);
51-
},
52-
logout() {
53-
return this.get('session').invalidate();
54-
}
21+
login() {
22+
return this.get('session').authenticate('authenticator:authmaker');
23+
},
24+
logout() {
25+
return this.get('session').invalidate();
5526
}
27+
}
5628
});
29+
5730
```
5831

5932
These actions are placed in the application controller so we can call them from our application template. In the example below, buttons for login/logout are placed in our header above the application outlet, so they will be visible and functional on all pages of our application.
6033

6134
```javascript {data-filename=app/templates/application.hbs}
6235
<header>
6336
{{#if session.isAuthenticated}}
64-
<button {{action 'logout'}}>Logout</button>
37+
<button {{action "logout"}}>Logout</button>
6538
{{else}}
66-
<button {{action 'login'}}>Login</button>
39+
<button {{action "login"}}>Login</button>
6740
{{/if}}
6841
</header>
6942

guides/pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
url: "create-database"
2121
- title: "Create an Authmaker instance"
2222
url: "authmaker-instance"
23-
- title: "Configure your app"
23+
- title: "Create your app"
2424
url: "configure-app"
25-
- title: "Create login route"
25+
- title: "Create login button"
2626
url: "login"
2727

2828
- title: "Building a Backend"

public/images/dummy-app.png

54.2 KB
Loading

public/images/instance.png

6.12 KB
Loading

0 commit comments

Comments
 (0)