fix: update error logs
This commit is contained in:
@@ -43,7 +43,7 @@ func (mgr *manager) AddSession(session Session) error {
|
|||||||
DoNothing: true,
|
DoNothing: true,
|
||||||
}).Create(&session)
|
}).Create(&session)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
log.Println(`Error saving session`, res.Error)
|
log.Println(`error saving session`, res.Error)
|
||||||
return res.Error
|
return res.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,6 +55,7 @@ func (mgr *manager) AddSession(session Session) error {
|
|||||||
sessionCollection, _ := mgr.arangodb.Collection(nil, Collections.Session)
|
sessionCollection, _ := mgr.arangodb.Collection(nil, Collections.Session)
|
||||||
_, err := sessionCollection.CreateDocument(nil, session)
|
_, err := sessionCollection.CreateDocument(nil, session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println(`error saving session`, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -159,9 +159,6 @@ func (mgr *manager) GetUserByEmail(email string) (User, error) {
|
|||||||
}
|
}
|
||||||
defer cursor.Close()
|
defer cursor.Close()
|
||||||
|
|
||||||
log.Println("=> query:", query, bindVars)
|
|
||||||
log.Println("=> cursor:", cursor.Count())
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
_, err := cursor.ReadDocument(nil, &user)
|
_, err := cursor.ReadDocument(nil, &user)
|
||||||
if driver.IsNoMoreDocuments(err) {
|
if driver.IsNoMoreDocuments(err) {
|
||||||
|
@@ -35,7 +35,7 @@ func (mgr *manager) AddVerification(verification VerificationRequest) (Verificat
|
|||||||
}).Create(&verification)
|
}).Create(&verification)
|
||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Println(`Error saving verification record`, result.Error)
|
log.Println(`error saving verification record`, result.Error)
|
||||||
return verification, result.Error
|
return verification, result.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,6 @@ func (mgr *manager) AddVerification(verification VerificationRequest) (Verificat
|
|||||||
verificationRequestCollection, _ := mgr.arangodb.Collection(nil, Collections.VerificationRequest)
|
verificationRequestCollection, _ := mgr.arangodb.Collection(nil, Collections.VerificationRequest)
|
||||||
meta, err := verificationRequestCollection.CreateDocument(nil, verification)
|
meta, err := verificationRequestCollection.CreateDocument(nil, verification)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("=> meta information for verification request:", meta.Key)
|
|
||||||
return verification, err
|
return verification, err
|
||||||
}
|
}
|
||||||
verification.Key = meta.Key
|
verification.Key = meta.Key
|
||||||
@@ -60,7 +59,7 @@ func (mgr *manager) GetVerificationRequests() ([]VerificationRequest, error) {
|
|||||||
if IsSQL {
|
if IsSQL {
|
||||||
result := mgr.sqlDB.Find(&verificationRequests)
|
result := mgr.sqlDB.Find(&verificationRequests)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Println(result.Error)
|
log.Println("error getting verification requests:", result.Error)
|
||||||
return verificationRequests, result.Error
|
return verificationRequests, result.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,7 @@ func (mgr *manager) GetVerificationByToken(token string) (VerificationRequest, e
|
|||||||
result := mgr.sqlDB.Where("token = ?", token).First(&verification)
|
result := mgr.sqlDB.Where("token = ?", token).First(&verification)
|
||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Println(`Error getting verification token:`, result.Error)
|
log.Println(`error getting verification request:`, result.Error)
|
||||||
return verification, result.Error
|
return verification, result.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,9 +119,7 @@ func (mgr *manager) GetVerificationByToken(token string) (VerificationRequest, e
|
|||||||
defer cursor.Close()
|
defer cursor.Close()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
meta, err := cursor.ReadDocument(nil, &verification)
|
_, err := cursor.ReadDocument(nil, &verification)
|
||||||
|
|
||||||
log.Println("=> arangodb verification by token:", verification, meta)
|
|
||||||
|
|
||||||
if driver.IsNoMoreDocuments(err) {
|
if driver.IsNoMoreDocuments(err) {
|
||||||
break
|
break
|
||||||
@@ -141,7 +138,7 @@ func (mgr *manager) GetVerificationByEmail(email string) (VerificationRequest, e
|
|||||||
result := mgr.sqlDB.Where("email = ?", email).First(&verification)
|
result := mgr.sqlDB.Where("email = ?", email).First(&verification)
|
||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Println(`Error getting verification token:`, result.Error)
|
log.Println(`error getting verification token:`, result.Error)
|
||||||
return verification, result.Error
|
return verification, result.Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,9 +156,7 @@ func (mgr *manager) GetVerificationByEmail(email string) (VerificationRequest, e
|
|||||||
defer cursor.Close()
|
defer cursor.Close()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
meta, err := cursor.ReadDocument(nil, &verification)
|
_, err := cursor.ReadDocument(nil, &verification)
|
||||||
|
|
||||||
log.Println("=> arangodb verification by token:", verification, meta)
|
|
||||||
|
|
||||||
if driver.IsNoMoreDocuments(err) {
|
if driver.IsNoMoreDocuments(err) {
|
||||||
break
|
break
|
||||||
@@ -186,7 +181,6 @@ func (mgr *manager) DeleteVerificationRequest(verificationRequest VerificationRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if IsArangoDB {
|
if IsArangoDB {
|
||||||
log.Println("vkey:", verificationRequest, verificationRequest.Key)
|
|
||||||
collection, _ := mgr.arangodb.Collection(nil, Collections.VerificationRequest)
|
collection, _ := mgr.arangodb.Collection(nil, Collections.VerificationRequest)
|
||||||
_, err := collection.RemoveDocument(nil, verificationRequest.Key)
|
_, err := collection.RemoveDocument(nil, verificationRequest.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -35,7 +35,7 @@ func InitEnv() {
|
|||||||
|
|
||||||
err := godotenv.Load(envPath)
|
err := godotenv.Load(envPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error loading .env file")
|
log.Println("error loading .env file")
|
||||||
}
|
}
|
||||||
|
|
||||||
constants.VERSION = Version
|
constants.VERSION = Version
|
||||||
|
@@ -129,7 +129,7 @@ func processFacebookUserInfo(code string) (db.User, error) {
|
|||||||
|
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("err processing facebook user info:", err)
|
log.Println("error processing facebook user info:", err)
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,6 @@ func OAuthCallbackHandler() gin.HandlerFunc {
|
|||||||
// user exists in db, check if method was google
|
// user exists in db, check if method was google
|
||||||
// if not append google to existing signup method and save it
|
// if not append google to existing signup method and save it
|
||||||
|
|
||||||
log.Println("existing useR:", existingUser)
|
|
||||||
signupMethod := existingUser.SignupMethod
|
signupMethod := existingUser.SignupMethod
|
||||||
if !strings.Contains(signupMethod, provider) {
|
if !strings.Contains(signupMethod, provider) {
|
||||||
signupMethod = signupMethod + "," + provider
|
signupMethod = signupMethod + "," + provider
|
||||||
|
@@ -19,7 +19,7 @@ func GinContextToContextMiddleware() gin.HandlerFunc {
|
|||||||
if constants.AUTHORIZER_URL == "" {
|
if constants.AUTHORIZER_URL == "" {
|
||||||
url := location.Get(c)
|
url := location.Get(c)
|
||||||
constants.AUTHORIZER_URL = url.Scheme + "://" + c.Request.Host
|
constants.AUTHORIZER_URL = url.Scheme + "://" + c.Request.Host
|
||||||
log.Println("=> setting url:", constants.AUTHORIZER_URL)
|
log.Println("=> authorizer url:", constants.AUTHORIZER_URL)
|
||||||
}
|
}
|
||||||
ctx := context.WithValue(c.Request.Context(), "GinContextKey", c)
|
ctx := context.WithValue(c.Request.Context(), "GinContextKey", c)
|
||||||
c.Request = c.Request.WithContext(ctx)
|
c.Request = c.Request.WithContext(ctx)
|
||||||
@@ -33,7 +33,6 @@ func CORSMiddleware() gin.HandlerFunc {
|
|||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
origin := c.Request.Header.Get("Origin")
|
origin := c.Request.Header.Get("Origin")
|
||||||
constants.APP_URL = origin
|
constants.APP_URL = origin
|
||||||
log.Println("=> APP_URL:", constants.APP_URL)
|
|
||||||
c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
|
c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
|
||||||
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
|
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
|
||||||
|
@@ -69,7 +69,7 @@ func AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*m
|
|||||||
verificationType := enum.UpdateEmail.String()
|
verificationType := enum.UpdateEmail.String()
|
||||||
token, err := utils.CreateVerificationToken(newEmail, verificationType)
|
token, err := utils.CreateVerificationToken(newEmail, verificationType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`Error generating token`, err)
|
log.Println(`error generating token`, err)
|
||||||
}
|
}
|
||||||
db.Mgr.AddVerification(db.VerificationRequest{
|
db.Mgr.AddVerification(db.VerificationRequest{
|
||||||
Token: token,
|
Token: token,
|
||||||
@@ -110,7 +110,7 @@ func AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*m
|
|||||||
|
|
||||||
user, err = db.Mgr.UpdateUser(user)
|
user, err = db.Mgr.UpdateUser(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error updating user:", err)
|
log.Println("error updating user:", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ func DeleteUser(ctx context.Context, params model.DeleteUserInput) (*model.Respo
|
|||||||
|
|
||||||
err = db.Mgr.DeleteUser(user)
|
err = db.Mgr.DeleteUser(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Err:", err)
|
log.Println("error deleting user:", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ func ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*mod
|
|||||||
|
|
||||||
token, err := utils.CreateVerificationToken(params.Email, enum.ForgotPassword.String())
|
token, err := utils.CreateVerificationToken(params.Email, enum.ForgotPassword.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`Error generating token`, err)
|
log.Println(`error generating token`, err)
|
||||||
}
|
}
|
||||||
db.Mgr.AddVerification(db.VerificationRequest{
|
db.Mgr.AddVerification(db.VerificationRequest{
|
||||||
Token: token,
|
Token: token,
|
||||||
|
@@ -43,7 +43,7 @@ func Login(ctx context.Context, params model.LoginInput) (*model.AuthResponse, e
|
|||||||
err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(params.Password))
|
err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(params.Password))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Compare password error:", err)
|
log.Println("compare password error:", err)
|
||||||
return res, fmt.Errorf(`invalid password`)
|
return res, fmt.Errorf(`invalid password`)
|
||||||
}
|
}
|
||||||
roles := constants.DEFAULT_ROLES
|
roles := constants.DEFAULT_ROLES
|
||||||
|
@@ -94,7 +94,7 @@ func MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Respo
|
|||||||
user.SignupMethod = signupMethod
|
user.SignupMethod = signupMethod
|
||||||
user, _ = db.Mgr.UpdateUser(user)
|
user, _ = db.Mgr.UpdateUser(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("=> error updating user:", err)
|
log.Println("error updating user:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ func MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Respo
|
|||||||
verificationType := enum.MagicLink.String()
|
verificationType := enum.MagicLink.String()
|
||||||
token, err := utils.CreateVerificationToken(params.Email, verificationType)
|
token, err := utils.CreateVerificationToken(params.Email, verificationType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`Error generating token`, err)
|
log.Println(`error generating token`, err)
|
||||||
}
|
}
|
||||||
db.Mgr.AddVerification(db.VerificationRequest{
|
db.Mgr.AddVerification(db.VerificationRequest{
|
||||||
Token: token,
|
Token: token,
|
||||||
|
@@ -27,7 +27,7 @@ func ResendVerifyEmail(ctx context.Context, params model.ResendVerifyEmailInput)
|
|||||||
|
|
||||||
token, err := utils.CreateVerificationToken(params.Email, verificationRequest.Identifier)
|
token, err := utils.CreateVerificationToken(params.Email, verificationRequest.Identifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`Error generating token`, err)
|
log.Println(`error generating token`, err)
|
||||||
}
|
}
|
||||||
db.Mgr.AddVerification(db.VerificationRequest{
|
db.Mgr.AddVerification(db.VerificationRequest{
|
||||||
Token: token,
|
Token: token,
|
||||||
|
@@ -51,7 +51,7 @@ func Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse,
|
|||||||
// find user with email
|
// find user with email
|
||||||
existingUser, err := db.Mgr.GetUserByEmail(params.Email)
|
existingUser, err := db.Mgr.GetUserByEmail(params.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("User with email " + params.Email + " not found")
|
log.Println("user with email " + params.Email + " not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if existingUser.EmailVerifiedAt > 0 {
|
if existingUser.EmailVerifiedAt > 0 {
|
||||||
@@ -103,7 +103,7 @@ func Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse,
|
|||||||
verificationType := enum.BasicAuthSignup.String()
|
verificationType := enum.BasicAuthSignup.String()
|
||||||
token, err := utils.CreateVerificationToken(params.Email, verificationType)
|
token, err := utils.CreateVerificationToken(params.Email, verificationType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`Error generating token`, err)
|
log.Println(`error generating token`, err)
|
||||||
}
|
}
|
||||||
db.Mgr.AddVerification(db.VerificationRequest{
|
db.Mgr.AddVerification(db.VerificationRequest{
|
||||||
Token: token,
|
Token: token,
|
||||||
|
@@ -109,7 +109,7 @@ func UpdateProfile(ctx context.Context, params model.UpdateProfileInput) (*model
|
|||||||
verificationType := enum.UpdateEmail.String()
|
verificationType := enum.UpdateEmail.String()
|
||||||
token, err := utils.CreateVerificationToken(newEmail, verificationType)
|
token, err := utils.CreateVerificationToken(newEmail, verificationType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(`Error generating token`, err)
|
log.Println(`error generating token`, err)
|
||||||
}
|
}
|
||||||
db.Mgr.AddVerification(db.VerificationRequest{
|
db.Mgr.AddVerification(db.VerificationRequest{
|
||||||
Token: token,
|
Token: token,
|
||||||
@@ -126,7 +126,7 @@ func UpdateProfile(ctx context.Context, params model.UpdateProfileInput) (*model
|
|||||||
|
|
||||||
_, err = db.Mgr.UpdateUser(user)
|
_, err = db.Mgr.UpdateUser(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error updating user:", err)
|
log.Println("error updating user:", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
message := `Profile details updated successfully.`
|
message := `Profile details updated successfully.`
|
||||||
|
@@ -3,7 +3,6 @@ package resolvers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -22,7 +21,6 @@ func VerifyEmail(ctx context.Context, params model.VerifyEmailInput) (*model.Aut
|
|||||||
}
|
}
|
||||||
|
|
||||||
verificationRequest, err := db.Mgr.GetVerificationByToken(params.Token)
|
verificationRequest, err := db.Mgr.GetVerificationByToken(params.Token)
|
||||||
log.Println("=> vf req:", verificationRequest)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, fmt.Errorf(`invalid token`)
|
return res, fmt.Errorf(`invalid token`)
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,8 +29,6 @@ func (c *InMemoryStore) AddToken(userId, accessToken, refreshToken string) {
|
|||||||
c.store[userId] = tempMap
|
c.store[userId] = tempMap
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(c.store)
|
|
||||||
|
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ func (c *RedisStore) GetToken(userId, accessToken string) string {
|
|||||||
token := ""
|
token := ""
|
||||||
res, err := c.store.HMGet(c.ctx, "authorizer_"+userId, accessToken).Result()
|
res, err := c.store.HMGet(c.ctx, "authorizer_"+userId, accessToken).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error getting token from redis store:", err)
|
log.Println("error getting token from redis store:", err)
|
||||||
}
|
}
|
||||||
if len(res) > 0 && res[0] != nil {
|
if len(res) > 0 && res[0] != nil {
|
||||||
token = fmt.Sprintf("%v", res[0])
|
token = fmt.Sprintf("%v", res[0])
|
||||||
@@ -66,7 +66,7 @@ func (c *RedisStore) GetSocialLoginState(key string) string {
|
|||||||
state := ""
|
state := ""
|
||||||
state, err := c.store.Get(c.ctx, key).Result()
|
state, err := c.store.Get(c.ctx, key).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error getting token from redis store:", err)
|
log.Println("error getting token from redis store:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
@@ -96,7 +96,7 @@ func RemoveSocialLoginState(key string) {
|
|||||||
|
|
||||||
func InitSession() {
|
func InitSession() {
|
||||||
if constants.REDIS_URL != "" {
|
if constants.REDIS_URL != "" {
|
||||||
log.Println("Using redis store to save sessions")
|
log.Println("using redis store to save sessions")
|
||||||
opt, err := redis.ParseURL(constants.REDIS_URL)
|
opt, err := redis.ParseURL(constants.REDIS_URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Error parsing redis url:", err)
|
log.Fatalln("Error parsing redis url:", err)
|
||||||
@@ -114,7 +114,7 @@ func InitSession() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.Println("Using in memory store to save sessions")
|
log.Println("using in memory store to save sessions")
|
||||||
SessionStoreObj.InMemoryStoreObj = &InMemoryStore{
|
SessionStoreObj.InMemoryStoreObj = &InMemoryStore{
|
||||||
store: map[string]map[string]string{},
|
store: map[string]map[string]string{},
|
||||||
socialLoginState: map[string]string{},
|
socialLoginState: map[string]string{},
|
||||||
|
@@ -64,12 +64,12 @@ func CreateAuthToken(user db.User, tokenType enum.TokenType, roles []string) (st
|
|||||||
val, err := vm.Get("functionRes")
|
val, err := vm.Get("functionRes")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("=> err custom access token script:", err)
|
log.Println("error getting custom access token script:", err)
|
||||||
} else {
|
} else {
|
||||||
extraPayload := make(map[string]interface{})
|
extraPayload := make(map[string]interface{})
|
||||||
err = json.Unmarshal([]byte(fmt.Sprintf("%s", val)), &extraPayload)
|
err = json.Unmarshal([]byte(fmt.Sprintf("%s", val)), &extraPayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error converting accessTokenScript response to map:", err)
|
log.Println("error converting accessTokenScript response to map:", err)
|
||||||
} else {
|
} else {
|
||||||
for k, v := range extraPayload {
|
for k, v := range extraPayload {
|
||||||
customClaims[k] = v
|
customClaims[k] = v
|
||||||
|
Reference in New Issue
Block a user