Skip to content

Commit

Permalink
Use convenience functions in documentations
Browse files Browse the repository at this point in the history
The examples can be simplified to use the convenience functions offered by the
library.
  • Loading branch information
robinbrandt committed Aug 12, 2023
1 parent 9f71679 commit 7e1aa40
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,12 @@ func BeginRegistration(w http.ResponseWriter, r *http.Request) {
}

func FinishRegistration(w http.ResponseWriter, r *http.Request) {
response, err := protocol.ParseCredentialCreationResponseBody(r.Body)
if err != nil {
// Handle Error and return.

return
}

user := datastore.GetUser() // Get the user

// Get the session data stored from the function above
session := datastore.GetSession()

credential, err := webAuthn.CreateCredential(user, session, response)
credential, err := webAuthn.FinishRegistration(user, session, r)
if err != nil {
// Handle Error and return.

Expand Down Expand Up @@ -141,19 +134,12 @@ func BeginLogin(w http.ResponseWriter, r *http.Request) {
}

func FinishLogin(w http.ResponseWriter, r *http.Request) {
response, err := protocol.ParseCredentialRequestResponseBody(r.Body)
if err != nil {
// Handle Error and return.

return
}

user := datastore.GetUser() // Get the user

// Get the session data stored from the function above
session := datastore.GetSession()

credential, err := webAuthn.ValidateLogin(user, session, response)
credential, err := webAuthn.FinishLogin(user, session, r)
if err != nil {
// Handle Error and return.

Expand Down

0 comments on commit 7e1aa40

Please sign in to comment.