Documentation
¶
Index ¶
- type CreateUserOpts
- type LoginInput
- type LoginResult
- type PgRepo
- func (r *PgRepo) FindByID(ctx context.Context, id uuid.UUID) (*User, error)
- func (r *PgRepo) FindByUsername(ctx context.Context, username string) (*User, error)
- func (r *PgRepo) Save(ctx context.Context, u *User) error
- func (r *PgRepo) Update(ctx context.Context, u *User) error
- func (r *PgRepo) VerifyPassword(ctx context.Context, username, password string) error
- type RegisterInput
- type Repo
- type Routes
- type UpdatePasswordInput
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateUserOpts ¶
type LoginInput ¶
type LoginResult ¶
type PgRepo ¶
type PgRepo struct {
// contains filtered or unexported fields
}
func (*PgRepo) FindByUsername ¶
type RegisterInput ¶
type Repo ¶
type Repo interface {
Save(ctx context.Context, u *User) error
FindByID(ctx context.Context, id uuid.UUID) (*User, error)
FindByUsername(ctx context.Context, username string) (*User, error)
VerifyPassword(ctx context.Context, username, password string) error // IDK
Update(ctx context.Context, u *User) error
}
type Routes ¶
type Routes struct {
// contains filtered or unexported fields
}
func (*Routes) FindByID ¶
FindByID
@ID User-FindByID
@Summary Find User By ID
@Tags users
@Accept json
@Produce json
@Param id path string true "User ID"
@Success 200 {object} User
@Failure 400
@Failure 500
@Router /users/{id} [get]
func (*Routes) Login ¶
Login
@ID User-Login @Summary Login With Credentials @Tags users @Accept json @Produce json @Param credentials body LoginInput true "User Credentials" @Success 200 @Failure 400 @Failure 500 @Router /users/login [post]
func (*Routes) Register ¶
Register
@ID User-Register @Summary Register New User @Tags users @Accept json @Produce json @Param options body RegisterInput true "New User Info" @Success 201 @Failure 400 @Failure 500 @Router /users/register [post]
func (*Routes) UpdatePassword ¶
UpdatePassword
@ID User-Update-Password
@Summary Upate Password
@Tags users
@Security BearerAuth
@Accept json
@Produce json
@Param credentials body UpdatePasswordInput true "User Credentials and New Password"
@Success 200 {object} User
@Failure 400
@Failure 500
@Router /users/update-password [patch]
type UpdatePasswordInput ¶
type User ¶
type User struct {
ID uuid.UUID `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
HashedPassword []byte `json:"-"`
Bio string `json:"bio"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func CreateUser ¶
func CreateUser(opts CreateUserOpts) (User, error)
CreateUser creates brand new user with new ID!
func (*User) UpdateEmail ¶
func (*User) UpdatePassword ¶
Click to show internal directories.
Click to hide internal directories.