add google login
- refactor resolvers - fix signup method typos Resolves #17
This commit is contained in:
@@ -3,26 +3,34 @@ package constants
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/yauthdev/yauth/server/enum"
|
||||
)
|
||||
|
||||
var (
|
||||
ENV = ""
|
||||
DB_TYPE = ""
|
||||
DB_URL = ""
|
||||
SMTP_HOST = ""
|
||||
SMTP_PORT = ""
|
||||
SENDER_EMAIL = ""
|
||||
SENDER_PASSWORD = ""
|
||||
JWT_TYPE = ""
|
||||
JWT_SECRET = ""
|
||||
FRONTEND_URL = ""
|
||||
PORT = "8080"
|
||||
REDIS_URL = ""
|
||||
IS_PROD = false
|
||||
COOKIE_NAME = ""
|
||||
ENV = ""
|
||||
DB_TYPE = ""
|
||||
DB_URL = ""
|
||||
SMTP_HOST = ""
|
||||
SMTP_PORT = ""
|
||||
SENDER_EMAIL = ""
|
||||
SENDER_PASSWORD = ""
|
||||
JWT_TYPE = ""
|
||||
JWT_SECRET = ""
|
||||
FRONTEND_URL = ""
|
||||
SERVER_URL = ""
|
||||
PORT = "8080"
|
||||
REDIS_URL = ""
|
||||
IS_PROD = false
|
||||
COOKIE_NAME = ""
|
||||
GOOGLE_CLIENT_ID = ""
|
||||
GOOGLE_CLIENT_SECRET = ""
|
||||
GITHUB_CLIENT_ID = ""
|
||||
GITHUB_CLIENT_SECRET = ""
|
||||
FACEBOOK_CLIENT_ID = ""
|
||||
FACEBOOK_CLIENT_SECRET = ""
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -40,10 +48,17 @@ func init() {
|
||||
SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD")
|
||||
JWT_SECRET = os.Getenv("JWT_SECRET")
|
||||
JWT_TYPE = os.Getenv("JWT_TYPE")
|
||||
FRONTEND_URL = os.Getenv("FRONTEND_URL")
|
||||
FRONTEND_URL = strings.TrimSuffix(os.Getenv("FRONTEND_URL"), "/")
|
||||
SERVER_URL = strings.TrimSuffix(os.Getenv("SERVER_URL"), "/")
|
||||
PORT = os.Getenv("PORT")
|
||||
REDIS_URL = os.Getenv("REDIS_URL")
|
||||
COOKIE_NAME = os.Getenv("COOKIE_NAME")
|
||||
GOOGLE_CLIENT_ID = os.Getenv("GOOGLE_CLIENT_ID")
|
||||
GOOGLE_CLIENT_SECRET = os.Getenv("GOOGLE_CLIENT_SECRET")
|
||||
GITHUB_CLIENT_ID = os.Getenv("GITHUB_CLIENT_ID")
|
||||
GITHUB_CLIENT_SECRET = os.Getenv("GITHUB_CLIENT_SECRET")
|
||||
FACEBOOK_CLIENT_ID = os.Getenv("FACEBOOK_CLIENT_ID")
|
||||
FACEBOOK_CLIENT_SECRET = os.Getenv("FACEBOOK_CLIENT_SECRET")
|
||||
|
||||
if ENV == "" {
|
||||
ENV = "production"
|
||||
@@ -70,4 +85,8 @@ func init() {
|
||||
if COOKIE_NAME == "" {
|
||||
COOKIE_NAME = "yauth"
|
||||
}
|
||||
|
||||
if SERVER_URL == "" {
|
||||
SERVER_URL = "http://localhost:8080"
|
||||
}
|
||||
}
|
||||
|
10
server/constants/oauthInfoUrls.go
Normal file
10
server/constants/oauthInfoUrls.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package constants
|
||||
|
||||
var (
|
||||
// Ref: https://github.com/qor/auth/blob/master/providers/google/google.go
|
||||
GoogleUserInfoURL = "https://www.googleapis.com/oauth2/v3/userinfo"
|
||||
// Ref: https://github.com/qor/auth/blob/master/providers/facebook/facebook.go#L18
|
||||
FacebookUserInfoURL = "https://graph.facebook.com/me?access_token="
|
||||
// Ref: https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#3-your-github-app-accesses-the-api-with-the-users-access-token
|
||||
GithubUserInfoURL = "https://api.github.com/user"
|
||||
)
|
Reference in New Issue
Block a user