Documentation ¶
Index ¶
- type DB
- func (db *DB) AuthMiddleware(response http.ResponseWriter, request *http.Request, next http.HandlerFunc)
- func (db *DB) ChangePassword(user *User, newPassword []byte) (bool, error)
- func (db *DB) CheckRequest(request *http.Request) (bool, int64)
- func (db *DB) CheckSession(session *Session) bool
- func (db *DB) CreateSession(newSession *Session) error
- func (db *DB) CreateUser(newUser *User) error
- func (db *DB) ExistUser(name string) bool
- func (db *DB) GetUser(name string) (*User, error)
- func (db *DB) GetUserById(id int64) (*User, error)
- func (db *DB) GetUserSessions(user *User) ([]Session, error)
- func (db *DB) HasStorage(user *User) bool
- func (db *DB) InvalidateSession(session *Session) error
- func (db *DB) UpdateSessionCode(session *Session, newCode []byte) error
- type Session
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
func (*DB) AuthMiddleware ¶
func (db *DB) AuthMiddleware(response http.ResponseWriter, request *http.Request, next http.HandlerFunc)
func (*DB) ChangePassword ¶
func (*DB) CheckSession ¶
Check if the given session is valid or not
func (*DB) CreateSession ¶
Create a new session for the user
func (*DB) CreateUser ¶
Create a new user. If a user with the same name already a new error is returned, otherwise is returned the id of the new user
func (*DB) HasStorage ¶
func (*DB) InvalidateSession ¶
Invalidate a user session,. deleting the data from the database
type Session ¶
type Session struct { Id int64 `db:"ID"` UserId int64 `db:"user_ID" json:"userId"` UserAgent string `db:"user_agent" json:"userAgent"` CodeHash []byte `db:"code" json:"code"` SessionType string `db:"type" json:"sessionType"` LastUse int64 `db:"last_use" json:"lastUse"` }
Struct that contains the session informations
Click to show internal directories.
Click to hide internal directories.