UNPKG

2.79 kBMarkdownView Raw
1authmaker-ember-simple-auth
2==============================================================================
3
4This 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
6Compatibility
7------------------------------------------------------------------------------
8
9* Ember.js v2.18 or above
10* Ember CLI v2.13 or above
11* Node.js v8 or above
12
13
14Installation
15------------------------------------------------------------------------------
16
17Install this addon.
18
19```bash
20ember install authmaker-ember-simple-auth
21```
22
23this will setup a few defaults in your application and add a basic configuration
24to your environment config that you will need to update with the real config
25from the Authmaker Dashboard. Read the [official
26documentation](https://beginner-guides.authmaker.com/release/implement-login/configure-app/)
27for more information.
28
29
30Usage
31------------------------------------------------------------------------------
32
33When you install this addon it will automatically generate a login route for
34you, along with a few other useful files. If you are starting an Ember app from
35scratch this should all be ok, but if you are adding Authmaker to an existing
36Ember app you might need to have a look at the diffs and see how to integrate
37your code into the provided files.
38
39This addon ultimately uses
40[ember-simple-auth](https://github.com/simplabs/ember-simple-auth) to provide
41the login functionality and you can follow their documentation to find out more.
42
43Here is an example of a controller that is providing a login action that makes
44use of Ember Simple Auth's `session.authenticate()` functionality:
45
46```js
47import Controller from '@ember/controller';
48import { inject as service } from '@ember/service'
49
50export 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
63with 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
73Contributing
74------------------------------------------------------------------------------
75
76See the [Contributing](CONTRIBUTING.md) guide for details.
77
78
79License
80------------------------------------------------------------------------------
81
82This project is licensed under the [MIT License](LICENSE.md).