Browse Source

make sure auth secret is set only once

abhishek9686 1 year ago
parent
commit
920ac4c507
2 changed files with 3 additions and 3 deletions
  1. 1 1
      auth/auth.go
  2. 2 2
      logic/auth.go

+ 1 - 1
auth/auth.go

@@ -75,7 +75,7 @@ func InitializeAuthProvider() string {
 		return ""
 	}
 	logger.Log(0, "setting oauth secret")
-	var err = logic.SetAuthSecret(auth_key, logic.RandomString(64))
+	var err = logic.SetAuthSecret(logic.RandomString(64))
 	if err != nil {
 		logger.FatalLog("failed to set auth_secret", err.Error())
 	}

+ 2 - 2
logic/auth.go

@@ -289,7 +289,7 @@ func DeleteUser(user string) (bool, error) {
 	return true, nil
 }
 
-func SetAuthSecret(key, secret string) error {
+func SetAuthSecret(secret string) error {
 	type valueHolder struct {
 		Value string `json:"value" bson:"value"`
 	}
@@ -306,7 +306,7 @@ func SetAuthSecret(key, secret string) error {
 		Value: b64NewValue,
 	}
 	d, _ := json.Marshal(newValueHolder)
-	return database.Insert(key, string(d), database.GENERATED_TABLE_NAME)
+	return database.Insert(auth_key, string(d), database.GENERATED_TABLE_NAME)
 }
 
 // FetchAuthSecret - manages secrets for oauth