Skip to content

Commit 93c7541

Browse files
Adding some basic docs
1 parent 8064230 commit 93c7541

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,39 @@ Or install it yourself as:
2222

2323
## Usage
2424

25-
TODO: Write usage instructions here
25+
In your `routes.rb`, please add:
26+
27+
```ruby
28+
mount Tokenable::Engine => '/api/auth'
29+
```
30+
31+
And in your `User` model, please add an Auth strategy, such as:
32+
33+
```ruby
34+
class User < ApplicationRecord
35+
include Tokenable::Strategies::SecurePassword
36+
37+
has_secure_password
38+
end
39+
```
40+
41+
You can chose from:
42+
43+
- `Tokenable::Strategies::SecurePassword`
44+
- `Tokenable::Strategies::Devise`
45+
46+
You can also create your own stragery. (TODO: link to docs on this)
47+
48+
Once you have this setup, you can login. For example, you could login using `axios` in JavaScript:
49+
50+
```js
51+
const { data } = await axios.post("https://example.com/api/auth", {
52+
53+
password: "coolpassword123",
54+
});
55+
56+
console.log(data.data.token);
57+
```
2658

2759
## Development
2860

0 commit comments

Comments
 (0)