Documentation
¶
Index ¶
- Variables
- func CallbackHandler(w http.ResponseWriter, r *http.Request)
- func JWT(token *jwt.Token) (interface{}, error)
- func LoginHandler(w http.ResponseWriter, r *http.Request)
- func ShowClaims(w http.ResponseWriter, r *http.Request)
- type BytegolfUser
- type BytegolfUserProfile
- type Claims
- type GithubUser
Constants ¶
This section is empty.
Variables ¶
var CookieName string
var ErrBadGithubStatus = errors.New("bad status code from github")
ErrBadGithubStatus gets returned from GetGithubUser if a 200 is not returned from github
Functions ¶
func CallbackHandler ¶
func CallbackHandler(w http.ResponseWriter, r *http.Request)
CallbackHandler is the callback from Github to grab the auth token
func LoginHandler ¶
func LoginHandler(w http.ResponseWriter, r *http.Request)
LoginHandler will send the request to Github to make sure that the user is logged in
func ShowClaims ¶
func ShowClaims(w http.ResponseWriter, r *http.Request)
ShowClaims shows the claims in the users cookie for the frontend
Types ¶
type BytegolfUser ¶
type BytegolfUser struct {
BGID string
LastUpdatedTime time.Time
CreatedTime time.Time
GithubUser GithubUser
}
BytegolfUser is the structure of how bytegolf user's are stored in the database
func BGUser ¶
func BGUser(ghu *GithubUser) (*BytegolfUser, error)
BGUser returns a bytegolf user based on the github user. Will create one if one does not exist yet
func NewBytegolfUser ¶
func NewBytegolfUser(ghu GithubUser) *BytegolfUser
NewBytegolfUser returns a new bytegolf user
func (*BytegolfUser) Collection ¶
func (bgu *BytegolfUser) Collection() *firestore.CollectionRef
func (*BytegolfUser) Data ¶
func (bgu *BytegolfUser) Data() interface{}
func (*BytegolfUser) DocID ¶
func (bgu *BytegolfUser) DocID() string
func (BytegolfUser) ToProfile ¶
func (bgu BytegolfUser) ToProfile() BytegolfUserProfile
ToProfile takes the BytegolfUser (Database object) and mutates it to a Profile (Frontend object)
type BytegolfUserProfile ¶
type BytegolfUserProfile struct {
BGID string `json:"BGID"`
DisplayName string `json:"DisplayName"`
GithubURL string `json:"GithubUrl"`
AvatarURL string `json:"AvatarUrl"`
}
BytegolfUserProfile is the BytegolfUser struct but with no sensitive fields
type Claims ¶
type Claims struct {
BGID string `json:"BGID"`
jwt.StandardClaims
}
Claims is what gets stored in the JWT
type GithubUser ¶
type GithubUser struct {
ID int64 `json:"id"`
Login string `json:"login"`
URL string `json:"html_url"`
AvatarURL string `json:"avatar_url"`
UpdatedAt time.Time `json:"updated_at"`
}
GithubUser is the object that comes back from github on a user lookup
func GetGithubUser ¶
func GetGithubUser(token string) (*GithubUser, error)
GetGithubUser gets a github user using their access token