aceberg/ForAuth

View on GitHub
internal/auth/session.go

Summary

Maintainability
A
0 mins
Test Coverage
package auth

import (
    "time"

    "github.com/gin-gonic/gin"

    "github.com/google/uuid"
)

// StartSession for new login
func StartSession(c *gin.Context) {

    sessionToken := uuid.NewString()

    allSessions[sessionToken] = time.Now().Add(60 * time.Second)

    setTokenCookie(c, sessionToken)

    // c.Redirect(http.StatusFound, "/")
}

// LogOut - log out
func LogOut(c *gin.Context) {

    sessionToken := getTokenFromCookie(c)

    delete(allSessions, sessionToken)

    setTokenCookie(c, "")

    // c.Redirect(http.StatusFound, "/")
}