Log `username` into the MemberSuite Portal.

    Returns a PortalUser object if successful, raises
    LoginToPortalError if not.

    Will retry logging in if a GeneralException occurs, up to `retries`.
    Will pause `delay` seconds between retries.
487603
def login_to_portal(username, password, client, retries=2, delay=0):
    
    if not client.session_id:
        client.request_session()

    concierge_request_header = client.construct_concierge_header(
        url=("http://membersuite.com/contracts/IConciergeAPIService/"
             "LoginToPortal"))

    attempts = 0
    while attempts < retries:
        if attempts:
            time.sleep(delay)

        result = client.client.service.LoginToPortal(
            _soapheaders=[concierge_request_header],
            portalUserName=username,
            portalPassword=password)

        login_to_portal_result = result["body"]["LoginToPortalResult"]

        if login_to_portal_result["Success"]:
            portal_user = login_to_portal_result["ResultValue"]["PortalUser"]

            session_id = get_session_id(result=result)

            return PortalUser(membersuite_object_data=portal_user,
                              session_id=session_id)
        else:
            attempts += 1
            try:
                error_code = login_to_portal_result[
                    "Errors"]["ConciergeError"][0]["Code"]
            except IndexError:  # Not a ConciergeError
                continue
            else:
                if attempts < retries and error_code == "GeneralException":
                    continue

    raise LoginToPortalError(result=result)
680793
def publicize_member(self, login):
        
        url = self._build_url('public_members', login, base_url=self._api)
        return self._boolean(self._put(url), 204, 404)
244018
def User(self, Username=''):
        
        if not Username:
            Username = self.CurrentUserHandle
        o = User(self, Username)
        o.OnlineStatus # Test if such a user exists.
        return o
747932
def user_logged_in(self, sender, request: AxesHttpRequest, user, **kwargs):  # pylint: disable=unused-argument
        

        # 1. database query: Clean up expired user attempts from the database
        clean_expired_user_attempts(request.axes_attempt_time)

        username = user.get_username()
        credentials = get_credentials(username)
        client_str = get_client_str(username, request.axes_ip_address, request.axes_user_agent, request.axes_path_info)

        log.info('AXES: Successful login by %s.', client_str)

        if not settings.AXES_DISABLE_SUCCESS_ACCESS_LOG:
            # 2. database query: Insert new access logs with login time
            AccessLog.objects.create(
                username=username,
                ip_address=request.axes_ip_address,
                user_agent=request.axes_user_agent,
                http_accept=request.axes_http_accept,
                path_info=request.axes_path_info,
                attempt_time=request.axes_attempt_time,
            )

        if settings.AXES_RESET_ON_SUCCESS:
            # 3. database query: Reset failed attempts for the logging in user
            count = reset_user_attempts(request, credentials)
            log.info('AXES: Deleted %d failed login attempts by %s from database.', count, client_str)
661040
private PortalUser getPortalUser(final String userName) {
        return jdbcOperations.execute(
                (ConnectionCallback<PortalUser>)
                        con -> {
                            PortalUser portalUser = null;
                            PreparedStatement pstmt = null;

                            try {
                                String query = "SELECT USER_ID FROM UP_USER WHERE USER_NAME=?";

                                pstmt = con.prepareStatement(query);
                                pstmt.setString(1, userName);

                                ResultSet rs = null;
                                try {
                                    if (log.isDebugEnabled())
                                        log.debug(
                                                "RDBMUserIdentityStore::getPortalUID(userName="
                                                        + userName
                                                        + "): "
                                                        + query);
                                    rs = pstmt.executeQuery();
                                    if (rs.next()) {
                                        portalUser = new PortalUser();
                                        portalUser.setUserId(rs.getInt("USER_ID"));
                                        portalUser.setUserName(userName);
                                    }
                                } finally {
                                    try {
                                        if (rs != null) {
                                            rs.close();
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            } finally {
                                try {
                                    if (pstmt != null) {
                                        pstmt.close();
                                    }
                                } catch (Exception e) {
                                }
                            }

                            return portalUser;
                        });
    }
1022736
def login_request(self, login_urls, is_retry=False):
        """"""
        try:
            login_url = login_urls.pop(0)
        except IndexError:
            _LOGGER.error("Could not login to blink servers.")
            return False

        _LOGGER.info("Attempting login with %s", login_url)

        response = api.request_login(self,
                                     login_url,
                                     self._username,
                                     self._password,
                                     is_retry=is_retry)
        try:
            if response.status_code != 200:
                response = self.login_request(login_urls)
            response = response.json()
            (self.region_id, self.region), = response['region'].items()

        except AttributeError:
            _LOGGER.error("Login API endpoint failed with response %s",
                          response,
                          exc_info=True)
            return False

        except KeyError:
            _LOGGER.warning("Could not extract region info.")
            self.region_id = 'piri'
            self.region = 'UNKNOWN'

        self._login_url = login_url
        return response
1280108
public static void logLoginException(
        CmsRequestContext requestContext,
        String userName,
        CmsException currentLoginException) {

        if (currentLoginException instanceof CmsAuthentificationException) {

            // the authentication of the user failed
            if (org.opencms.security.Messages.ERR_LOGIN_FAILED_DISABLED_2 == currentLoginException.getMessageContainer().getKey()) {

                // the user has been disabled
                LOG.warn(
                    Messages.get().getBundle().key(
                        Messages.LOG_LOGIN_FAILED_DISABLED_3,
                        userName,
                        requestContext.addSiteRoot(requestContext.getUri()),
                        requestContext.getRemoteAddress()));

            } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_TEMP_DISABLED_4 == currentLoginException.getMessageContainer().getKey()) {

                // the user has been disabled
                LOG.warn(
                    Messages.get().getBundle().key(
                        Messages.LOG_LOGIN_FAILED_TEMP_DISABLED_5,
                        new Object[] {
                            userName,
                            requestContext.addSiteRoot(requestContext.getUri()),
                            requestContext.getRemoteAddress(),
                            currentLoginException.getMessageContainer().getArgs()[2],
                            currentLoginException.getMessageContainer().getArgs()[3]}));

            } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_NO_USER_2 == currentLoginException.getMessageContainer().getKey()) {

                // the requested user does not exist in the database
                LOG.warn(
                    Messages.get().getBundle().key(
                        Messages.LOG_LOGIN_FAILED_NO_USER_3,
                        userName,
                        requestContext.addSiteRoot(requestContext.getUri()),
                        requestContext.getRemoteAddress()));

            } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_WITH_MESSAGE_1 == currentLoginException.getMessageContainer().getKey()) {

                // logins have been disabled by the administration
                long endTime = CmsLoginMessage.DEFAULT_TIME_END;
                if (OpenCms.getLoginManager().getLoginMessage() != null) {
                    endTime = OpenCms.getLoginManager().getLoginMessage().getTimeEnd();
                }
                LOG.info(
                    Messages.get().getBundle().key(
                        Messages.LOG_LOGIN_FAILED_WITH_MESSAGE_4,
                        new Object[] {
                            userName,
                            requestContext.addSiteRoot(requestContext.getUri()),
                            requestContext.getRemoteAddress(),
                            new Date(endTime)}));

            } else {

                // the user exists, so the password must have been wrong
                CmsMessageContainer message = Messages.get().container(
                    Messages.LOG_LOGIN_FAILED_3,
                    userName,
                    requestContext.addSiteRoot(requestContext.getUri()),
                    requestContext.getRemoteAddress());
                if (OpenCms.getDefaultUsers().isUserAdmin(userName)) {
                    // someone tried to log in as "Admin", log this in a higher channel
                    LOG.error(message.key());
                } else {
                    LOG.warn(message.key());
                }
            }
        } else {
            // the error was database related, there may be an issue with the setup
            // write the exception to the log as well
            LOG.error(
                Messages.get().getBundle().key(
                    Messages.LOG_LOGIN_FAILED_DB_REASON_3,
                    userName,
                    requestContext.addSiteRoot(requestContext.getUri()),
                    requestContext.getRemoteAddress()),
                currentLoginException);
        }
    }
369398
function login(user = {
    username: settings.username,
    password: settings.password
}) {
    return __awaiter(this, void 0, void 0, function* () {
        log_1.logger.info(`[API] Logging in ${user.username}`);
        if (exports.currentLogin !== null) {
            log_1.logger.debug(`[API] Already logged in`);
            if (exports.currentLogin.username === user.username) {
                return exports.currentLogin.result;
            }
            else {
                yield logout();
            }
        }
        const result = yield post('login', user, false);
        if (result && result.data && result.data.authToken) {
            exports.currentLogin = {
                result: result,
                username: user.username,
                authToken: result.data.authToken,
                userId: result.data.userId
            };
            setAuth(exports.currentLogin);
            log_1.logger.info(`[API] Logged in ID ${exports.currentLogin.userId}`);
            return result;
        }
        else {
            throw new Error(`[API] Login failed for ${user.username}`);
        }
    });
}
251274
def perform_login(request, user, email_verification,
                  redirect_url=None, signal_kwargs=None,
                  signup=False):
    
    # Local users are stopped due to form validation checking
    # is_active, yet, adapter methods could toy with is_active in a
    # `user_signed_up` signal. Furthermore, social users should be
    # stopped anyway.
    adapter = get_adapter(request)
    if not user.is_active:
        return adapter.respond_user_inactive(request, user)

    from .models import EmailAddress
    has_verified_email = EmailAddress.objects.filter(user=user,
                                                     verified=True).exists()
    if email_verification == EmailVerificationMethod.NONE:
        pass
    elif email_verification == EmailVerificationMethod.OPTIONAL:
        # In case of OPTIONAL verification: send on signup.
        if not has_verified_email and signup:
            send_email_confirmation(request, user, signup=signup)
    elif email_verification == EmailVerificationMethod.MANDATORY:
        if not has_verified_email:
            send_email_confirmation(request, user, signup=signup)
            return adapter.respond_email_verification_sent(
                request, user)
    try:
        adapter.login(request, user)
        response = HttpResponseRedirect(
            get_login_redirect_url(request, redirect_url))

        if signal_kwargs is None:
            signal_kwargs = {}
        signals.user_logged_in.send(sender=user.__class__,
                                    request=request,
                                    response=response,
                                    user=user,
                                    **signal_kwargs)
        adapter.add_message(
            request,
            messages.SUCCESS,
            'account/messages/logged_in.txt',
            {'user': user})
    except ImmediateHttpResponse as e:
        response = e.response
    return response
52134
def check_failed_login(self):
        
        last_attempt = self.get_last_failed_access_attempt()

        if not last_attempt:
            # create a new entry
            user_access = self._FailedAccessAttemptModel(ip_address=self.ip)
        elif last_attempt:
            user_access = last_attempt

        if self.request.method == 'POST':
            if self.username is None:
                raise DobermanImproperlyConfigured(
                    "Bad username form field, if you are using a custom field please configure: "
                    "DOBERMAN_USERNAME_FORM_FIELD via settings."
                )

            if self.response.status_code != 302:

                user_access.user_agent = self.request.META.get('HTTP_USER_AGENT', '<unknown user agent>')[:255]
                user_access.username = self.username
                user_access.failed_attempts += 1
                user_access.params_get = self.request.GET
                user_access.params_post = self.request.POST

                if user_access.failed_attempts >= self.max_failed_attempts:
                    user_access.is_locked = True

                user_access.save()

            elif self.response.status_code == 302 and not user_access.is_locked:
                user_access.is_expired = True
                user_access.save()

        return user_access
853293
def ReqUserLogin(self, user: str, pwd: str, broker: str):
        
        self.broker = broker
        self.investor = user
        self.password = pwd
        self.t.ReqUserLogin(BrokerID=broker, UserID=user, Password=pwd)
107164
def getUser(self):
        
        username = self.getUsername()
        if not username:
            return None
        user = api.user.get(userid=username)
        return user
1243035
def _resolve_username(self, account, username):
        """"""
        if account is not None:
            warnings.warn(
                "Use keyword argument 'username' instead of 'account'",
                DeprecationWarning)
        return username or account or self.username
633189
def login(username=None, password=None):
    
    global user
    user = UserConfig()
    if username:
        user.username = username
    else:
        user.username = user.input_username()

    if password:
        user.password = password
    else:
        user.password = user.input_password()

    if (not ( user.username and user.password) ):
        logging.error("Username and password must be provided for login")
        return;
    user.retrieve_keycloak_token()
    user.apiclient = user.create_api_client()
    save()
625248
def get_member(self, username, api=None):
        
        api = api if api else self._API

        response = api.get(
            url=self._URL['member'].format(id=self.id, username=username),
        )
        data = response.json()
        return Member(api=api, **data)
579
def login(self, request):
        
        try:
            user = authenticate(request)

            if not user:
                raise AuthenticationFailed("User not authenticated.")

            if not user.is_active:
                raise AuthenticationFailed("This user has been disabled.")

            login(request, user)

            return Response(UserSerializer(user).data)
        except AuthError as ex:
            # This indicates an error that may require attention by the
            # Treeherder or Taskcluster teams.  Logging this to New Relic to
            # increase visibility.
            newrelic.agent.record_exception()
            logger.exception("Error", exc_info=ex)
            raise AuthenticationFailed(str(ex))
384990
def get_user(self):
        
        for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
            user = os.environ.get(name)
            if user:
                break     
        for u in users:
            if u['name'] == user:
                return u['type'], u['name']