Documentation ¶
Index ¶
- func InitTokenExpiryIndex(ctx context.Context, collection *mongo.Collection) error
- func ValidateToken(token string, secret string) (*jwt.Token, error)
- type AboutMe
- type AccessDetails
- type GoogleLoginResponse
- type LoginResponse
- type MailingList
- type MediaCloudManager
- type Middleware
- type MiddlewareTokenManager
- type MiddlewareUserRepo
- type Role
- type Subscriber
- type TokenDetails
- type TokenManager
- func (tm *TokenManager) DeleteToken(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) error
- func (tm *TokenManager) ExtractTokenMetadata(token *jwt.Token) (*AccessDetails, error)
- func (tm *TokenManager) FindToken(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*AccessDetails, error)
- func (tm *TokenManager) GenerateToken(userId string) (*TokenDetails, error)
- func (tm *TokenManager) IsExists(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (bool, error)
- func (tm *TokenManager) SaveToken(ctx context.Context, userId string, td *TokenDetails) error
- type TokenMgr
- type Uploader
- type User
- type UserController
- func (uc *UserController) Callback(c *gin.Context)
- func (uc *UserController) GetAboutMe(c *gin.Context)
- func (uc *UserController) GetMailingList(c *gin.Context)
- func (uc *UserController) GetUsers(c *gin.Context)
- func (uc *UserController) Login(c *gin.Context)
- func (uc *UserController) Logout(c *gin.Context)
- func (uc *UserController) Profile(c *gin.Context)
- func (uc *UserController) SubscribeToMailingList(c *gin.Context)
- func (uc *UserController) UnSubscribeFromMailingList(c *gin.Context)
- func (uc *UserController) UpdateAboutMe(c *gin.Context)
- type UserRepo
- func (repo *UserRepo) CreateAboutMe(ctx context.Context, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (repo *UserRepo) CreateMailingList(ctx context.Context, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (repo *UserRepo) CreateUser(ctx context.Context, user *User) (*mongo.InsertOneResult, error)
- func (repo *UserRepo) GetAboutMe(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*AboutMe, error)
- func (repo *UserRepo) GetMailingList(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*MailingList, error)
- func (repo *UserRepo) GetUser(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*User, error)
- func (repo *UserRepo) GetUsers(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]*User, error)
- func (repo *UserRepo) IsExists(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (bool, error)
- func (repo *UserRepo) UpdateAboutMe(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (repo *UserRepo) UpdateMailingList(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (repo *UserRepo) UpdateUser(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type UserRepository
- type UserService
- func (us *UserService) Callback(ctx *gin.Context) (*GoogleLoginResponse, error)
- func (us *UserService) GenerateAccessToken(userId string) (*TokenDetails, error)
- func (us *UserService) GetAboutMe(ctx context.Context) (*AboutMe, error)
- func (us *UserService) GetMailingList(ctx context.Context) (*MailingList, error)
- func (us *UserService) GetUsers(ctx context.Context) ([]*User, error)
- func (us *UserService) Login(ctx *gin.Context) (string, error)
- func (us *UserService) Logout(ctx context.Context, accessUuid string) error
- func (us *UserService) Profile(ctx context.Context, userId string) (*User, error)
- func (us *UserService) SaveAccessToken(ctx context.Context, userId string, td *TokenDetails) error
- func (us *UserService) SaveUser(ctx context.Context, googleLoginResponse *GoogleLoginResponse) error
- func (us *UserService) SubscribeToMailingList(ctx context.Context, id string) error
- func (us *UserService) UnSubscribeFromMailingList(ctx context.Context, id string) error
- func (us *UserService) UpdateAboutMe(ctx context.Context, userId, aboutMe, profilePicture string) error
- type UserServices
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitTokenExpiryIndex ¶
func InitTokenExpiryIndex(ctx context.Context, collection *mongo.Collection) error
func ValidateToken ¶
Types ¶
type AccessDetails ¶
type GoogleLoginResponse ¶
type LoginResponse ¶
type LoginResponse struct { AccessToken string `json:"access_token"` AtExpires int64 `json:"at_expires"` GoogleLoginResponse }
type MailingList ¶
type MailingList struct { Name string `json:"name" bson:"name"` Subscribers []Subscriber `json:"subscribers" bson:"subscribers"` }
type MediaCloudManager ¶
type MediaCloudManager struct {
// contains filtered or unexported fields
}
func NewMediaCloudManager ¶
func NewMediaCloudManager(api_uri, folder string) (*MediaCloudManager, error)
func (*MediaCloudManager) UploadImage ¶
func (mcm *MediaCloudManager) UploadImage(ctx context.Context, file *multipart.FileHeader, collection string) (string, error)
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(accessTokenSecret string, userRepo MiddlewareUserRepo, tokenManager MiddlewareTokenManager) *Middleware
func (*Middleware) Authentication ¶
func (m *Middleware) Authentication() gin.HandlerFunc
func (*Middleware) Authorization ¶
func (m *Middleware) Authorization(roles []Role) gin.HandlerFunc
type MiddlewareTokenManager ¶
type MiddlewareTokenManager interface { FindToken(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*AccessDetails, error) ExtractTokenMetadata(token *jwt.Token) (*AccessDetails, error) }
type MiddlewareUserRepo ¶
type Subscriber ¶
type TokenDetails ¶
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
func NewTokenManager ¶
func NewTokenManager(accessTokenSecret string, accessTokenValidaityInHours int64, collection *mongo.Collection) *TokenManager
func (*TokenManager) DeleteToken ¶
func (tm *TokenManager) DeleteToken(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) error
func (*TokenManager) ExtractTokenMetadata ¶
func (tm *TokenManager) ExtractTokenMetadata(token *jwt.Token) (*AccessDetails, error)
func (*TokenManager) FindToken ¶
func (tm *TokenManager) FindToken(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*AccessDetails, error)
func (*TokenManager) GenerateToken ¶
func (tm *TokenManager) GenerateToken(userId string) (*TokenDetails, error)
func (*TokenManager) IsExists ¶
func (tm *TokenManager) IsExists(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (bool, error)
func (*TokenManager) SaveToken ¶
func (tm *TokenManager) SaveToken(ctx context.Context, userId string, td *TokenDetails) error
type TokenMgr ¶
type TokenMgr interface { SaveToken(ctx context.Context, userId string, td *TokenDetails) error GenerateToken(userId string) (*TokenDetails, error) FindToken(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*AccessDetails, error) IsExists(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (bool, error) DeleteToken(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) error }
type User ¶
type User struct { ID string `json:"id" bson:"_id,omitempty"` Name string `json:"name" bson:"name"` Email string `json:"email" bson:"email"` IsVerified bool `json:"is_verified" bson:"is_verified"` Role Role `json:"role" bson:"role"` Picture string `json:"picture" bson:"picture"` CreatedAt time.Time `json:"created_at" bson:"created_at"` UpdatedAt time.Time `json:"updated_at" bson:"updated_at"` }
type UserController ¶
type UserController struct {
// contains filtered or unexported fields
}
func NewUserController ¶
func NewUserController(service UserServices, uploader Uploader) *UserController
func (*UserController) Callback ¶
func (uc *UserController) Callback(c *gin.Context)
func (*UserController) GetAboutMe ¶
func (uc *UserController) GetAboutMe(c *gin.Context)
func (*UserController) GetMailingList ¶
func (uc *UserController) GetMailingList(c *gin.Context)
func (*UserController) GetUsers ¶
func (uc *UserController) GetUsers(c *gin.Context)
func (*UserController) Login ¶
func (uc *UserController) Login(c *gin.Context)
func (*UserController) Logout ¶
func (uc *UserController) Logout(c *gin.Context)
func (*UserController) Profile ¶
func (uc *UserController) Profile(c *gin.Context)
func (*UserController) SubscribeToMailingList ¶
func (uc *UserController) SubscribeToMailingList(c *gin.Context)
func (*UserController) UnSubscribeFromMailingList ¶
func (uc *UserController) UnSubscribeFromMailingList(c *gin.Context)
func (*UserController) UpdateAboutMe ¶
func (uc *UserController) UpdateAboutMe(c *gin.Context)
type UserRepo ¶
type UserRepo struct {
// contains filtered or unexported fields
}
func NewUserRepo ¶
func NewUserRepo(collection *mongo.Collection) *UserRepo
func (*UserRepo) CreateAboutMe ¶
func (repo *UserRepo) CreateAboutMe(ctx context.Context, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (*UserRepo) CreateMailingList ¶
func (repo *UserRepo) CreateMailingList(ctx context.Context, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (*UserRepo) CreateUser ¶
func (*UserRepo) GetAboutMe ¶
func (*UserRepo) GetMailingList ¶
func (repo *UserRepo) GetMailingList(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*MailingList, error)
func (*UserRepo) UpdateAboutMe ¶
func (repo *UserRepo) UpdateAboutMe(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*UserRepo) UpdateMailingList ¶
func (repo *UserRepo) UpdateMailingList(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*UserRepo) UpdateUser ¶
func (repo *UserRepo) UpdateUser(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type UserRepository ¶
type UserRepository interface { CreateUser(ctx context.Context, user *User) (*mongo.InsertOneResult, error) GetUser(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*User, error) GetUsers(ctx context.Context, filter interface{}, opts ...*options.FindOptions) ([]*User, error) UpdateUser(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) IsExists(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (bool, error) CreateAboutMe(ctx context.Context, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) GetAboutMe(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*AboutMe, error) UpdateAboutMe(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) CreateMailingList(ctx context.Context, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error) GetMailingList(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) (*MailingList, error) UpdateMailingList(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) }
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(repo UserRepository, tokenMgr TokenMgr) *UserService
func (*UserService) Callback ¶
func (us *UserService) Callback(ctx *gin.Context) (*GoogleLoginResponse, error)
func (*UserService) GenerateAccessToken ¶
func (us *UserService) GenerateAccessToken(userId string) (*TokenDetails, error)
func (*UserService) GetAboutMe ¶
func (us *UserService) GetAboutMe(ctx context.Context) (*AboutMe, error)
func (*UserService) GetMailingList ¶
func (us *UserService) GetMailingList(ctx context.Context) (*MailingList, error)
func (*UserService) GetUsers ¶
func (us *UserService) GetUsers(ctx context.Context) ([]*User, error)
func (*UserService) Logout ¶
func (us *UserService) Logout(ctx context.Context, accessUuid string) error
func (*UserService) SaveAccessToken ¶
func (us *UserService) SaveAccessToken(ctx context.Context, userId string, td *TokenDetails) error
func (*UserService) SaveUser ¶
func (us *UserService) SaveUser(ctx context.Context, googleLoginResponse *GoogleLoginResponse) error
func (*UserService) SubscribeToMailingList ¶
func (us *UserService) SubscribeToMailingList(ctx context.Context, id string) error
func (*UserService) UnSubscribeFromMailingList ¶
func (us *UserService) UnSubscribeFromMailingList(ctx context.Context, id string) error
func (*UserService) UpdateAboutMe ¶
func (us *UserService) UpdateAboutMe(ctx context.Context, userId, aboutMe, profilePicture string) error
type UserServices ¶
type UserServices interface { Login(ctx *gin.Context) (string, error) Callback(ctx *gin.Context) (*GoogleLoginResponse, error) SaveAccessToken(ctx context.Context, userId string, td *TokenDetails) error GenerateAccessToken(userId string) (*TokenDetails, error) SaveUser(ctx context.Context, googleLoginResponse *GoogleLoginResponse) error Logout(ctx context.Context, accessUuid string) error Profile(ctx context.Context, userId string) (*User, error) UpdateAboutMe(ctx context.Context, userId, aboutMe, profilePicture string) error GetAboutMe(ctx context.Context) (*AboutMe, error) SubscribeToMailingList(ctx context.Context, id string) error UnSubscribeFromMailingList(ctx context.Context, id string) error GetMailingList(ctx context.Context) (*MailingList, error) GetUsers(ctx context.Context) ([]*User, error) }
Click to show internal directories.
Click to hide internal directories.