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