UNPKG

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