The user table is used for Single Sign On deployments of the Marinus UI and contains the API key information. By default, an account for "marinus" is established regardless of whether there is an SSO account for marinus. This is because the "marinus" user is the default user when Marinu
(mongo_connector, username)
| 144 | |
| 145 | |
| 146 | def create_user(mongo_connector, username): |
| 147 | """ |
| 148 | The user table is used for Single Sign On deployments of the Marinus UI and contains the API key information. |
| 149 | By default, an account for "marinus" is established regardless of whether there is an SSO account for marinus. |
| 150 | This is because the "marinus" user is the default user when Marinus is used in development mode. |
| 151 | """ |
| 152 | user_collection = mongo_connector.get_users_connection() |
| 153 | |
| 154 | if user_collection.count_documents({}) > 0: |
| 155 | print("WARNING: The user collection already exists. Skipping initialization.") |
| 156 | return |
| 157 | |
| 158 | now = datetime.now() |
| 159 | |
| 160 | existing_check = user_collection.count_documents({"userid": username}) |
| 161 | if existing_check != 0: |
| 162 | print("User already exists!") |
| 163 | return |
| 164 | |
| 165 | randomValue = "".join( |
| 166 | [random.choice(string.ascii_letters + string.digits) for n in range(32)] |
| 167 | ) |
| 168 | |
| 169 | user_collection.insert_one( |
| 170 | {"userid": username, "status": "active", "created": now, "apiKey": randomValue} |
| 171 | ) |
| 172 | |
| 173 | |
| 174 | def create_first_groups(mongo_connector, username): |
no test coverage detected