Dada Hsueh commited on
Commit
8b574ab
·
1 Parent(s): 4361f57

fix `superuser` password not base64 encoded (#2475)

Browse files

### 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)

Files changed (1) hide show
  1. api/db/init_data.py +5 -1
api/db/init_data.py CHANGED
@@ -13,6 +13,7 @@
13
  # See the License for the specific language governing permissions and
14
  # limitations under the License.
15
  #
 
16
  import json
17
  import os
18
  import time
@@ -30,11 +31,14 @@ from api.db.services.user_service import TenantService, UserTenantService
30
  from api.settings import CHAT_MDL, EMBEDDING_MDL, ASR_MDL, IMAGE2TEXT_MDL, PARSERS, LLM_FACTORY, API_KEY, LLM_BASE_URL
31
  from api.utils.file_utils import get_project_base_directory
32
 
 
 
 
33
 
34
  def init_superuser():
35
  user_info = {
36
  "id": uuid.uuid1().hex,
37
- "password": "admin",
38
  "nickname": "admin",
39
  "is_superuser": True,
40
  "email": "[email protected]",
 
13
  # See the License for the specific language governing permissions and
14
  # limitations under the License.
15
  #
16
+ import base64
17
  import json
18
  import os
19
  import time
 
31
  from api.settings import CHAT_MDL, EMBEDDING_MDL, ASR_MDL, IMAGE2TEXT_MDL, PARSERS, LLM_FACTORY, API_KEY, LLM_BASE_URL
32
  from api.utils.file_utils import get_project_base_directory
33
 
34
+ def encode_to_base64(input_string):
35
+ base64_encoded = base64.b64encode(input_string.encode('utf-8'))
36
+ return base64_encoded.decode('utf-8')
37
 
38
  def init_superuser():
39
  user_info = {
40
  "id": uuid.uuid1().hex,
41
+ "password": encode_to_base64("admin"),
42
  "nickname": "admin",
43
  "is_superuser": True,
44
  "email": "[email protected]",