diff --git a/src/mab/bot/_client_auth.py b/src/mab/bot/_client_auth.py index 448a6b9..d424531 100644 --- a/src/mab/bot/_client_auth.py +++ b/src/mab/bot/_client_auth.py @@ -17,11 +17,14 @@ class ClientAuth: # # PRIVATE # - @staticmethod - async def _default_password_callback() -> str: + async def _default_password_callback(self) -> str: + if self._config is None: + raise RuntimeError("No config") if "MATRIX_PASSWORD" in os.environ: return os.environ["MATRIX_PASSWORD"] - return await aioconsole.ainput("Matrix password: ") + if self._config.allow_ainput_password: + return await aioconsole.ainput("Matrix password: ") + raise RuntimeError("Can't get password") async def _login_using_session_data(self, client: AsyncClient) -> None: """ @@ -98,11 +101,13 @@ class ClientAuth: self._logger = logging.getLogger("ClientAuth") self._storage = storage self._full_matrix_username: str | None = None + self._config: MatrixBotConfig | None = None async def setup(self, config: MatrixBotConfig) -> None: """ Setup `ClientAuth` object using `config`. """ + self._config = config self._full_matrix_username = Utils.build_full_matrix_username(config) async def login(self, client: AsyncClient) -> None: