auth

package
v0.0.0-...-523d496 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SessionData map[uint32]SessionInf

Functions

func AllowCORS

func AllowCORS(w http.ResponseWriter)

func CheckSession

func CheckSession(ctx context.Context, userID uint32, sessionID string) error

CheckSession checks if session is already stored in redis database (every time)

func CheckSessionHTTP

func CheckSessionHTTP(r io.Reader) error

CheckSessionHTTP check session from http request and return if session is not there

func DeleteAllExpiredSessions

func DeleteAllExpiredSessions()

DeleteAllExpiredSessions delete all sessions expired

func DeleteSessionHTTP

func DeleteSessionHTTP(r io.Reader) error

HTTTP CONNECTION MOJULE DeleteSessionHTTP check session from http request and return if session is not there

func GetSessionData

func GetSessionData(ctx context.Context, userID uint32) (string, error)

GetSessionData get sessionId (for CheckSession)

func Login

func Login(u model.User) (model.Session, error)

Login user login post User{User.id, User.email, User.password} if login success return sessionID, else return "" use u1.id not u.id, because u1.id is a stored id, but u.id is a requested id.

func NewLogin

func NewLogin(w http.ResponseWriter, r *http.Request)

NewLogin newLogin

func NewSession

func NewSession(ctx context.Context, userID uint32) (string, error)

NewSession creates and save new session

func Signup

func Signup(u model.User) (model.Session, error)

Signup user signup it might be better to email-configuration Post data User{ email, password }

func StartSessionManegement

func StartSessionManegement()

StartSessionManegement manage session

Types

type SessionInf

type SessionInf struct {
	SessionID string    `json:"session_id"` //session id
	Updated   time.Time `json:"updated"`    //last updated time
}

SessionInf is a information of session linked by "userID"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL