Documentation ¶
Index ¶
- Constants
- type AuthenticationService
- func (s *AuthenticationService) DeleteUserFromSession(w http.ResponseWriter, r *http.Request) error
- func (s *AuthenticationService) GetUserFromSession(r *http.Request) (User, error)
- func (s *AuthenticationService) SaveUser(ctx *gin.Context, gothUser goth.User) error
- func (s *AuthenticationService) SaveUserToSession(w http.ResponseWriter, r *http.Request, user User) error
- type ConnectedAccount
- type User
- type UserDetail
- type UserRepository
- func (r *UserRepository) CreateAccountWithConnectedAccount(ctx context.Context, connectedAccount ConnectedAccount) (accountId string, err error)
- func (r *UserRepository) CreateUser(ctx context.Context, user User) (savedUser User, err error)
- func (r *UserRepository) DeleteAccount(ctx context.Context, accountId string) (err error)
- func (r *UserRepository) DeleteUser(ctx context.Context, user User) (err error)
- func (r *UserRepository) GetConnectedAccount(ctx context.Context, provider string, providerUserId string) (connectedAccount ConnectedAccount, err error)
- func (r *UserRepository) GetUser(ctx context.Context, name string) (user User, err error)
- func (r *UserRepository) GetUserWithDetailById(ctx context.Context, id string) (user User, err error)
- func (r *UserRepository) SoftDeleteUser(ctx context.Context, user User) (err error)
Constants ¶
View Source
const SESSION_KEY_USER = "user"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationService ¶
type AuthenticationService struct {
// contains filtered or unexported fields
}
func NewAuthenticationService ¶
func NewAuthenticationService(db *sql.DB, sessionStore *databases.SessionStore) *AuthenticationService
func (*AuthenticationService) DeleteUserFromSession ¶
func (s *AuthenticationService) DeleteUserFromSession(w http.ResponseWriter, r *http.Request) error
func (*AuthenticationService) GetUserFromSession ¶
func (s *AuthenticationService) GetUserFromSession(r *http.Request) (User, error)
func (*AuthenticationService) SaveUserToSession ¶
func (s *AuthenticationService) SaveUserToSession(w http.ResponseWriter, r *http.Request, user User) error
type ConnectedAccount ¶
type ConnectedAccount struct { Id int64 `json:"-" db:"id"` UserId string `json:"-" db:"user_id"` Provider string `json:"provider" db:"provider"` ProviderUserId string `json:"provider_user_id" db:"provider_user_id"` Name string `json:"name" db:"name"` Email string `json:"email" db:"email"` Phone string `json:"phone" db:"phone"` Location string `json:"location" db:"location"` Nickname string `json:"nickname" db:"nickname"` Description string `json:"description" db:"description"` AvatarUrl string `json:"avatar_url" db:"avatar_url"` AccessToken string `json:"access_token" db:"access_token"` AccessSecret string `json:"access_secret" db:"access_secret"` RefreshToken string `json:"refresh_token" db:"refresh_token"` IdToken string `json:"id_token" db:"id_token"` RawData string `json:"raw_data" db:"raw_data,omitempty"` ExpiresAt sql.NullTime `json:"expires_at" db:"expires_at,omitempty"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
func NewConnectedAccountFromGothUser ¶
func NewConnectedAccountFromGothUser(gothUser goth.User) (ConnectedAccount, error)
type User ¶
type User struct { Id string `json:"id" db:"id"` Name string `json:"name" db:"name"` Email string `json:"email" db:"email,omitempty"` Phone string `json:"phone" db:"phone,omitempty"` VerifiedAt sql.NullTime `json:"-" db:"verified_at,omitempty"` DeletedAt sql.NullTime `json:"-" db:"deleted_at,omitempty"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` UserDetail *UserDetail `json:"user_detail"` }
func (*User) IsVerified ¶
type UserDetail ¶
type UserDetail struct { Id string `json:"-" db:"id"` Nickname string `json:"nickname" db:"nickname"` AvatarUrl string `json:"avatar_url" db:"avatar_url"` Description string `json:"description" db:"description"` Location string `json:"location" db:"location"` CreatedAt time.Time `json:"-" db:"created_at"` UpdatedAt time.Time `json:"-" db:"updated_at"` }
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
func NewUserRepository ¶
func NewUserRepository(db *sql.DB) *UserRepository
func (*UserRepository) CreateAccountWithConnectedAccount ¶
func (r *UserRepository) CreateAccountWithConnectedAccount(ctx context.Context, connectedAccount ConnectedAccount) (accountId string, err error)
Create an account with ConnectedAccount, insert data into users, user_details and connected_accounts tables. Return the user id.
func (*UserRepository) CreateUser ¶
func (*UserRepository) DeleteAccount ¶
func (r *UserRepository) DeleteAccount(ctx context.Context, accountId string) (err error)
Delete an account with id.
func (*UserRepository) DeleteUser ¶
func (r *UserRepository) DeleteUser(ctx context.Context, user User) (err error)
func (*UserRepository) GetConnectedAccount ¶
func (r *UserRepository) GetConnectedAccount( ctx context.Context, provider string, providerUserId string, ) (connectedAccount ConnectedAccount, err error)
func (*UserRepository) GetUserWithDetailById ¶
func (*UserRepository) SoftDeleteUser ¶
func (r *UserRepository) SoftDeleteUser(ctx context.Context, user User) (err error)
Click to show internal directories.
Click to hide internal directories.