File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments