You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,11 +39,21 @@ For other authentication solutions or custom Devise setups, you must first use p
39
39
40
40
`authenticate:` specifies the name of the method on the User model which accepts a password to authenticate the user. This is the name of an instance method on the User model which accepts the `password` param, and returns either true or false to indicate authentication.
41
41
42
+
Proof also allows for a optional block that returns a hash to modify the json return
43
+
44
+
proof_actions authenticatable: :User do |user, token|
45
+
{
46
+
user_id: user.id,
47
+
email: user.email,
48
+
auth_token: token
49
+
}
50
+
end
51
+
42
52
When your application sends a `POST` request to the `login` action, it will return JSON with the key `auth_token` if it finds a valid user. Your application must then save this token and send it with every request under the `Authorization` HTTP header, in the Bearer format: `Bearer [token]`.
43
53
44
54
You must route the `login` action yourself. For example, if you had a controller named `AuthenticationController`, you could create a `/login` route like so:
45
55
46
-
post '/login' => 'authentication#login'
56
+
post '/login', to: 'authentication#login'
47
57
48
58
In order to restrict an action to authenticated users, simply use a `before_action` call for the actions you'd like to restrict:
0 commit comments