Implement login resolver (#15)

* add sign_up_method to users table

* add session store

* implement login resolver
This commit is contained in:
Lakhan Samani
2021-07-15 00:13:19 +05:30
committed by GitHub
parent 336fe10ca4
commit 27264c6e29
20 changed files with 874 additions and 884 deletions

View File

@@ -9,8 +9,9 @@ import (
)
var (
DB_TYPE = enum.Postgres
DB_URL = "postgresql://localhost:5432/postgres"
ENV = ""
DB_TYPE = ""
DB_URL = ""
SMTP_HOST = ""
SMTP_PORT = ""
SENDER_EMAIL = ""
@@ -18,6 +19,10 @@ var (
JWT_TYPE = ""
JWT_SECRET = ""
FRONTEND_URL = ""
PORT = "8080"
REDIS_URL = ""
IS_PROD = false
COOKIE_NAME = ""
)
func init() {
@@ -26,6 +31,9 @@ func init() {
log.Println("Error loading .env file")
}
ENV = os.Getenv("ENV")
DB_TYPE = os.Getenv("DB_TYPE")
DB_URL = os.Getenv("DB_URL")
SMTP_HOST = os.Getenv("SMTP_HOST")
SMTP_PORT = os.Getenv("SMTP_PORT")
SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
@@ -33,4 +41,33 @@ func init() {
JWT_SECRET = os.Getenv("JWT_SECRET")
JWT_TYPE = os.Getenv("JWT_TYPE")
FRONTEND_URL = os.Getenv("FRONTEND_URL")
PORT = os.Getenv("PORT")
REDIS_URL = os.Getenv("REDIS_URL")
COOKIE_NAME = os.Getenv("COOKIE_NAME")
if ENV == "" {
ENV = "production"
}
if ENV == "production" {
IS_PROD = true
} else {
IS_PROD = false
}
if DB_TYPE == "" {
DB_TYPE = enum.Postgres.String()
}
if DB_URL == "" {
DB_TYPE = "postgresql://localhost:5432/postgres"
}
if JWT_TYPE == "" {
JWT_TYPE = "HS256"
}
if COOKIE_NAME == "" {
COOKIE_NAME = "yauth"
}
}