Skip to content

Commit ea3d033

Browse files
committed
Updated the README. [skip ci]
1 parent 15fa962 commit ea3d033

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,28 @@ This will add the `config/initializers/passkeys_rails.rb` configuration file, pa
8080
<a id="rails-Integration-standard"></a>
8181
## Rails Integration <p><small>Adding to a standard rails project</small></p>
8282

83-
1. Add `before_action :authenticate_passkey!`
83+
- ### Add `before_action :authenticate_passkey!`
8484

85-
To prevent access to controller actions, add `before_action :authenticate_passkey!`. If an action is attempted without an authenticated entity, an error will be rendered in JSON with an :unauthorized result code.
85+
To prevent access to controller actions, add `before_action :authenticate_passkey!`. If an action is attempted without an authenticated entity, an error will be rendered in JSON with an :unauthorized result code.
8686

87-
1. Use `current_agent` and `current_agent.authenticatable`
87+
- ### Use `current_agent` and `current_agent.authenticatable`
8888

89-
To access the currently authenticated entity, use `current_agent`. If you associated the registration of the agent with one of your own models, use `current_agent.authenticatable`. For example, if you associated the `User` class with the registration, `current_agent.authenticatable` will be a User object.
89+
To access the currently authenticated entity, use `current_agent`. If you associated the registration of the agent with one of your own models, use `current_agent.authenticatable`. For example, if you associated the `User` class with the registration, `current_agent.authenticatable` will be a User object.
9090

91-
1. Add `include PasskeysRails::Authenticatable` to model class(es)
91+
- ### Add `include PasskeysRails::Authenticatable` to model class(es)
9292

9393
If you have one or more classes that you want to use with authentication - e.g. a User class and an AdminUser class - add `include PasskeysRails::Authenticatable` to each of those classes. That adds a `registered?` method that you can call on your model to determine if they are registerd with your service, and a `registering_with(params)` method that you can override to initialize attributes of your model when it is created during registration. `params` is a hash with params passed to the API when registering. When called, your object has been built, but not yet saved. Upon return, **PasskeysRails** will attempt to save your object before finishing registration. If it is not valid, the registration will fail as well, returning the error error details to the caller.
9494

9595
<a id="rails-Integration-grape"></a>
9696
## Rails Integration - <p><small>Adding to a Grape API rails project</small></p>
9797

98-
1. Call `PasskeysRails.authenticate(request)` to authenticate the request.
98+
- ### Call `PasskeysRails.authenticate(request)` to authenticate the request.
9999

100100
Call `PasskeysRails.authenticate(request)` to get an object back that responds to `.success?` and `.failure?` as well as `.agent`, `.code`, and `.message`.
101101

102102
Alternatively, call `PasskeysRails.authenticate!(request)` from a helper in your base class. It will raise a `PasskeysRails.Error` exception if the caller isn't authenticated. You can catch the exception and render an appropriate error. The exception contains the error code and message.
103103

104-
1. Consider adding the following helpers to your base API class:
104+
- ### Consider adding the following helpers to your base API class:
105105

106106
```ruby
107107
helpers do
@@ -130,7 +130,7 @@ This will add the `config/initializers/passkeys_rails.rb` configuration file, pa
130130

131131
To prevent access to various endpoints, add `before_action :authenticate_passkey!` or call `authenticate_passkey!` from any method that requires authentication. If an action is attempted without an authenticated entity, an error will be rendered in JSON with an :unauthorized result code.
132132

133-
1. Use `current_agent` and `current_agent.authenticatable`
133+
- ### Use `current_agent` and `current_agent.authenticatable`
134134

135135
To access the currently authenticated entity, use `current_agent`. If you associated the registration of the agent with one of your own models, use `current_agent.authenticatable`. For example, if you associated the `User` class with the registration, `current_agent.authenticatable` will be a User object.
136136

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy