Skip to content

Instantly share code, notes, and snippets.

View Renrensan's full-sized avatar

Pasha Renaisan Renrensan

View GitHub Profile
package auth
import (
"context"
"errors"
"fmt"
"time"
"github.com/Renrensan/go-auth-demo/db"
"github.com/Renrensan/go-auth-demo/utils"
package auth
import (
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
// RegisterAuthRoutes sets up authentication-related routes on the provided router group.
// It takes the Gin router group, GORM database connection, and Redis client as dependencies.
package auth
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
package auth
import (
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
// RegisterAuthRoutes sets up authentication-related routes on the provided router group.
// It takes the Gin router group, GORM database connection, and Redis client as dependencies.
package auth
import (
"github.com/Renrensan/go-auth-demo/utils"
"github.com/gin-gonic/gin"
)
// AuthController is responsible for handling authentication-related HTTP requests.
// It communicates with the AuthService to process authentication logic.
type AuthController struct {
package auth
import (
"github.com/Renrensan/go-auth-demo/utils"
)
// AuthService contains the business logic for authentication operations.
type AuthService struct {
authRepository IAuthRepository // Repository for accessing data (e.g., user information)
}
package auth
import (
"context"
"errors"
"fmt"
"time"
"github.com/Renrensan/go-auth-demo/db"
"github.com/Renrensan/go-auth-demo/utils"
package auth
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
#Postgresdb
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=go-auth-demo-db
DB_PORT=5432
#Redis
REDIS_ADDRESS=localhost:6379
REDIS_PASSWORD=goauthdemoredispass
package auth
import (
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
// RegisterAuthRoutes sets up authentication-related routes on the provided router group.
// It takes the Gin router group, GORM database connection, and Redis client as dependencies.