Skip to content

Commit

Permalink
fix superuser password not base64 encoded (infiniflow#2475)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Fixes the _superuser_ `[email protected]` not being accessible due to how
entered passwords are used. Unless this is expected behavior?

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
dadahsueh authored Sep 18, 2024
1 parent e4e2975 commit 71c90d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/db/init_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import base64
import json
import os
import time
Expand All @@ -30,11 +31,14 @@
from api.settings import CHAT_MDL, EMBEDDING_MDL, ASR_MDL, IMAGE2TEXT_MDL, PARSERS, LLM_FACTORY, API_KEY, LLM_BASE_URL
from api.utils.file_utils import get_project_base_directory

def encode_to_base64(input_string):
base64_encoded = base64.b64encode(input_string.encode('utf-8'))
return base64_encoded.decode('utf-8')

def init_superuser():
user_info = {
"id": uuid.uuid1().hex,
"password": "admin",
"password": encode_to_base64("admin"),
"nickname": "admin",
"is_superuser": True,
"email": "[email protected]",
Expand Down

0 comments on commit 71c90d5

Please sign in to comment.