# Path: rocketchat_API/APIExceptions/RocketExceptions.py
# class RocketAuthenticationException(Exception):
#     pass
# 
# class RocketConnectionException(Exception):
#     pass


import re
import requests
from rocketchat_API.APIExceptions.RocketExceptions import (
    RocketAuthenticationException,
    RocketConnectionException,
)
            self.server_url + self.API_path + method,
            data=reduced_args,
            files=files,
            headers=self.headers,
            verify=self.ssl_verify,
            cert=self.cert,
            proxies=self.proxies,
            timeout=self.timeout,
        )

    # Authentication

    def login(self, user, password):
        request_data = {"password": password}
        if re.match(
            r"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",
            user,
        ):
            request_data["user"] = user
        else:
            request_data["username"] = user
        login_request = requests.post(
            self.server_url + self.API_path + "login",
            data=request_data,
            verify=self.ssl_verify,
            proxies=self.proxies,
            cert=self.cert,
            timeout=self.timeout,
        )
        if login_request.status_code == 401:

# Path: rocketchat_API/APIExceptions/RocketExceptions.py
# class RocketAuthenticationException(Exception):
#     pass
# 
# class RocketConnectionException(Exception):
#     pass


# Path: rocketchat_API/APISections/base.py
import re
import requests
from rocketchat_API.APIExceptions.RocketExceptions import (
    RocketAuthenticationException,
    RocketConnectionException,
)

            self.server_url + self.API_path + method,
            data=reduced_args,
            files=files,
            headers=self.headers,
            verify=self.ssl_verify,
            cert=self.cert,
            proxies=self.proxies,
            timeout=self.timeout,
        )

    # Authentication

    def login(self, user, password):
        request_data = {"password": password}
        if re.match(
            r"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",
            user,
        ):
            request_data["user"] = user
        else:
            request_data["username"] = user
        login_request = requests.post(
            self.server_url + self.API_path + "login",
            data=request_data,
            verify=self.ssl_verify,
            proxies=self.proxies,
            cert=self.cert,
            timeout=self.timeout,
        )
        if login_request.status_code == 401:

            raise RocketAuthenticationException()