Documentation
¶
Index ¶
- Variables
- func HashPassword(password string) string
- type BlacklistRepository
- type EventInvalidateCache
- type EventType
- type JWTService
- type Permission
- type Post
- type PostCache
- type PostKey
- type PostMessage
- type PostRepository
- type Sex
- type SocialNetworkService
- type TokenString
- type User
- type UserClaims
- type UserKey
- type UserLastActivity
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func HashPassword ¶
Types ¶
type BlacklistRepository ¶
type EventInvalidateCache ¶
type EventInvalidateCache struct { UserID UserKey `json:"user_id"` EventType EventType `json:"event_type"` }
EventInvalidateCache представляет структуру события для Kafka.
type JWTService ¶
type JWTService interface { GenerateToken(userID UserKey, permissions []Permission) (TokenString, error) ValidateToken(tokenString TokenString) (*jwt.Token, error) RevokeToken(token *jwt.Token) error ExtractClaims(token *jwt.Token) (*UserClaims, error) }
type PostMessage ¶
type PostMessage string
type PostRepository ¶
type PostRepository interface { List(userId UserKey, limit int, lastPostId PostKey) ([]*Post, error) Create(userId UserKey, message PostMessage) (PostKey, error) Get(postId PostKey) (*Post, error) GetPostOwner(postId PostKey) (UserKey, error) UpdateMessage(postId PostKey, newMessage PostMessage) error Delete(id PostKey) error GetFeed(userId UserKey, limit int) ([]*Post, error) }
type SocialNetworkService ¶
type SocialNetworkService interface { CreateUser(user *User) (UserKey, error) GetUser(id UserKey) (*User, error) Search(firstName, lastName string) ([]*User, error) Login(username, password string) (TokenString, error) AddFriend(my_id, friend_id UserKey) error RemoveFriend(my_id, friend_id UserKey) error Logout(token *jwt.Token) error ListPosts(userId UserKey, limit int, lastPostId PostKey) ([]*Post, error) CreatePost(userId UserKey, message PostMessage) (PostKey, error) GetPost(userId UserKey, postId PostKey) (*Post, error) UpdatePost(userId UserKey, postId PostKey, newMessage PostMessage) error DeletePost(userId UserKey, postId PostKey) error GetFeed(userId UserKey) ([]*Post, error) SetLastActivity(userId UserKey) error }
type TokenString ¶
type TokenString string
type User ¶
type User struct { ID UserKey `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Sex Sex `json:"sex"` Birthdate time.Time `json:"birthdate"` Biography string `json:"biography"` City string `json:"city"` Username string `json:"username"` PasswordHash string `json:"-"` // Не экспортируем пароль через API CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
func (*User) CheckPassword ¶
func (*User) SetPassword ¶
type UserClaims ¶
type UserClaims struct { Permissions []Permission `json:"permissions"` jwt.RegisteredClaims }
UserClaims - структура для хранения кастомных claims
type UserLastActivity ¶
type UserRepository ¶
type UserRepository interface { RegisterUser(user *User) (UserKey, error) GetByID(id UserKey) (*User, error) GetByUsername(username string) (*User, error) Search(firstName, lastName string) ([]*User, error) AddFriend(my_id, friend_id UserKey) error RemoveFriend(my_id, friend_id UserKey) error GetFriendsIds(id UserKey) ([]UserKey, error) SetLastActivity(id UserKey) error GetUsersActiveSince(period time.Duration) ([]UserKey, error) }
Click to show internal directories.
Click to hide internal directories.