1 | authmaker-ember-simple-auth
|
2 | ==============================================================================
|
3 |
|
4 | This addon allows you to get started very quickly with [Authmaker](https://authmaker.com) and [ember-simple-auth](https://github.com/simplabs/ember-simple-auth). This Readme has some basic information about how to use the addon but if you want a more in-depth description on how to use it you can check the [Authmaker Guides](https://beginner-guides.authmaker.com/release/)
|
5 |
|
6 | Compatibility
|
7 | ------------------------------------------------------------------------------
|
8 |
|
9 | * Ember.js v2.18 or above
|
10 | * Ember CLI v2.13 or above
|
11 | * Node.js v8 or above
|
12 |
|
13 |
|
14 | Installation
|
15 | ------------------------------------------------------------------------------
|
16 |
|
17 | Install this addon.
|
18 |
|
19 | ```bash
|
20 | ember install authmaker-ember-simple-auth
|
21 | ```
|
22 |
|
23 | this will setup a few defaults in your application and add a basic configuration
|
24 | to your environment config that you will need to update with the real config
|
25 | from the Authmaker Dashboard. Read the [official
|
26 | documentation](https://beginner-guides.authmaker.com/release/implement-login/configure-app/)
|
27 | for more information.
|
28 |
|
29 |
|
30 | Usage
|
31 | ------------------------------------------------------------------------------
|
32 |
|
33 | When you install this addon it will automatically generate a login route for
|
34 | you, along with a few other useful files. If you are starting an Ember app from
|
35 | scratch this should all be ok, but if you are adding Authmaker to an existing
|
36 | Ember app you might need to have a look at the diffs and see how to integrate
|
37 | your code into the provided files.
|
38 |
|
39 | This addon ultimately uses
|
40 | [ember-simple-auth](https://github.com/simplabs/ember-simple-auth) to provide
|
41 | the login functionality and you can follow their documentation to find out more.
|
42 |
|
43 | Here is an example of a controller that is providing a login action that makes
|
44 | use of Ember Simple Auth's `session.authenticate()` functionality:
|
45 |
|
46 | ```js
|
47 | import Controller from '@ember/controller';
|
48 | import { inject as service } from '@ember/service'
|
49 |
|
50 | export default Controller.extend({
|
51 | session: service(),
|
52 | actions: {
|
53 | login() {
|
54 | this.get('session').authenticate('authenticator:authmaker');
|
55 | },
|
56 | logout() {
|
57 | this.get('session').invalidate();
|
58 | }
|
59 | }
|
60 | });
|
61 | ```
|
62 |
|
63 | with this in place you can make use of these actions in the template as follows:
|
64 |
|
65 | ```handlebars
|
66 | {{#if session.isAuthenticated}}
|
67 | <button {{action 'logout'}}>logout</button>
|
68 | {{else}}
|
69 | <button {{action 'login'}}>login</button>
|
70 | {{/if}}
|
71 | ```
|
72 |
|
73 | Contributing
|
74 | ------------------------------------------------------------------------------
|
75 |
|
76 | See the [Contributing](CONTRIBUTING.md) guide for details.
|
77 |
|
78 |
|
79 | License
|
80 | ------------------------------------------------------------------------------
|
81 |
|
82 | This project is licensed under the [MIT License](LICENSE.md).
|