r--w / pocketbase

PocketBase Go SDK
MIT License
83 stars 30 forks source link

extend authstore functionalites #64

Open hsedr opened 1 year ago

hsedr commented 1 year ago

Which part of the project should be enhanced?

Auth-Store

Description of the problem.

Right now one cannot access the data, which pocketbase sends back when the authentication was successful.

Solution

The solution is to extend the authResponse-struct, such that the record/admin field of the JSON-Response is parsed into it. The data could be exposed by a function which takes in a struct and maps the data.

// after authentication
type Record struct {
  ID string `json:"id"`
  Username string `json:"username"`
  Email string `json:"email"`
  ...
}
var record Record
client.AuthStore().Model(&record)

I think that the providing the struct from outside is the right choice here because the response could contain custom fields.