users

package module
v0.0.0-...-b8db7ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2023 License: MIT Imports: 1 Imported by: 58

README

users

Go Reference

Package users provides a users service definition.

Installation

go get github.com/shurcooL/users

Directories

Path Synopsis
githubapi Package githubapi implements users.Service using GitHub API client.

License

Documentation

Overview

Package users provides a users service definition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EditRequest

type EditRequest struct {
}

EditRequest represents a request to edit a user.

type Service

type Service interface {
	// Get fetches the specified user.
	Get(ctx context.Context, user UserSpec) (User, error)

	// GetAuthenticatedSpec fetches the currently authenticated
	// user specification, or UserSpec{ID: 0} if there is no
	// authenticated user. A non-nil error is returned if the
	// the authentication process was not able to successfully
	// determine if a user or no user is currently authenticated.
	GetAuthenticatedSpec(ctx context.Context) (UserSpec, error)

	// GetAuthenticated fetches the currently authenticated user,
	// or User{UserSpec: UserSpec{ID: 0}} if there is no authenticated user.
	GetAuthenticated(ctx context.Context) (User, error)

	// Edit the authenticated user.
	Edit(ctx context.Context, er EditRequest) (User, error)
}

Service for users.

type Store

type Store interface {
	// Create creates the specified user.
	// UserSpec must specify a valid (i.e., non-zero) user.
	// It returns os.ErrExist if the user already exists.
	Create(ctx context.Context, user User) error

	// Get fetches the specified user.
	Get(ctx context.Context, user UserSpec) (User, error)
}

Store for users.

type User

type User struct {
	// UserSpec is the primary user identity. It is mostly used for user equivalence,
	// and potentially for authentication for well-known domains (e.g., "github.com").
	UserSpec
	// CanonicalMe is an optional canonical user profile URL. When a non-zero value,
	// it is used for identifying users that authenticate via the IndieAuth protocol.
	CanonicalMe string

	// Elsewhere represents alternative user identities. This information is not used for
	// user equivalence or authentication purposes, but can be used for display purposes.
	Elsewhere []UserSpec

	Login     string
	Name      string
	Email     string // Public email.
	AvatarURL string
	HTMLURL   string

	SiteAdmin bool
}

User represents a user.

type UserSpec

type UserSpec struct {
	ID     uint64
	Domain string
}

UserSpec specifies a user. ID value 0 represents no user. Valid users may not use 0 as their ID.

Directories

Path Synopsis
Package githubapi implements users.Service using GitHub API client.
Package githubapi implements users.Service using GitHub API client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL