simple_jwt_auth 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3410eb7555c21ab78d237f49cd7ae8d70867936b4c5d123fddc950cacabd37
|
4
|
+
data.tar.gz: 981dc01478eeaad45523accb7420de4f8f563b610060e8d9d658e8652ea8e292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38cc551e81b6df1b8b20a4fbe4d9c2f143e85cbd552fe16778a7b7b875bf23ed1bb80b6a5e0da5e952e4dd47dcfae618e9fe92830a047fc5dbf38fd126ae288
|
7
|
+
data.tar.gz: 54c254551ec766af5892b5e090f359e8c44189c5d219beef6ac23fed19ed48c996f8556992efbf2346c2dbc64cf2a57bd7641c7e5427ece9555cac83210feee8
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# SimpleJwtAuth
|
2
|
-
|
3
|
-
|
4
|
-
## Usage
|
5
|
-
How to use my plugin.
|
2
|
+
This gem provides simple jwt authorization for rails API projects by giving you access to POST for users and sessions. Aswell as a current_user helper method.
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
Add this line to your application's Gemfile:
|
@@ -21,24 +18,36 @@ Or install it yourself as:
|
|
21
18
|
$ gem install simple_jwt_auth
|
22
19
|
```
|
23
20
|
|
24
|
-
|
21
|
+
## Usage
|
22
|
+
### Models
|
23
|
+
After installation run
|
25
24
|
```bash
|
26
25
|
$ rails simple_jwt_auth:install:migrations
|
27
26
|
```
|
27
|
+
this will create a user model in your rails application.
|
28
28
|
|
29
29
|
then run
|
30
30
|
```bash
|
31
31
|
$ rails db:migrate
|
32
32
|
```
|
33
|
-
|
33
|
+
### Routes
|
34
34
|
in order to access gems provided routes add
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
to top of routes in your rails project
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
```bash
|
36
|
+
mount SimpleJwtAuth::Engine, at: "/auth"
|
37
|
+
```
|
38
|
+
to the top of your routes in your rails project
|
39
|
+
### Creating Users
|
40
|
+
Users can be created by making a POST request to
|
41
|
+
https://localhost:3000/auth/users
|
42
|
+
With name, email, password, and password_confirmation as params
|
43
|
+
|
44
|
+
### Creating Sessions
|
45
|
+
Sessions can be created by making a POST request to
|
46
|
+
https://localhost:3000/auth/sessions
|
47
|
+
with email and password as params.
|
48
|
+
|
49
|
+
#### Logged in
|
50
|
+
Add header called "Authorization" and set it to "Bearer <your jwt token here>" include this in any request you want the user to be logged in for.
|
42
51
|
|
43
52
|
## License
|
44
53
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -2,7 +2,6 @@ require_dependency "simple_jwt_auth/application_controller"
|
|
2
2
|
|
3
3
|
module SimpleJwtAuth
|
4
4
|
class UsersController < ApplicationController
|
5
|
-
wrap_parameters :user, include: [:name, :email, :password, :password_confirmation]
|
6
5
|
|
7
6
|
def create
|
8
7
|
user = User.new(user_params)
|
@@ -17,9 +16,7 @@ module SimpleJwtAuth
|
|
17
16
|
private
|
18
17
|
|
19
18
|
def user_params
|
20
|
-
params
|
21
|
-
.require(:user)
|
22
|
-
.permit(:name, :email, :password, :password_confirmation)
|
19
|
+
params.permit(:name, :email, :password, :password_confirmation)
|
23
20
|
end
|
24
21
|
end
|
25
22
|
end
|