Sign in a signed out entry.

    :param entry: `models.Entry` object. The entry to sign back in.
    :param session: (optional) SQLAlchemy session through which to access the database.
342574
def undo_sign_out(entry, session=None):
     # noqa
    if session is None:
        session = Session()
    else:
        session = session

    entry_to_sign_in = (
        session
        .query(Entry)
        .filter(Entry.uuid == entry.uuid)
        .one_or_none()
    )

    if entry_to_sign_in:
        logger.info('Undo sign out: {}'.format(entry_to_sign_in.user_id))
        logger.debug('Undo sign out: {}'.format(entry_to_sign_in))
        entry_to_sign_in.time_out = None
        session.add(entry_to_sign_in)
        session.commit()
    else:
        error_message = 'Entry not found: {}'.format(entry)
        logger.error(error_message)
        raise ValueError(error_message)
295603
def login(self):
        
        form = self._get_form('SECURITY_LOGIN_FORM')
        if form.validate_on_submit():
            try:
                self.security_service.login_user(form.user, form.remember.data)
            except AuthenticationError as e:
                form._errors = {'_error': [str(e)]}
            else:
                self.after_this_request(self._commit)
                if request.is_json:
                    return self.jsonify({'token': form.user.get_auth_token(),
                                         'user': form.user})
                self.flash(_('flask_unchained.bundles.security:flash.login'),
                           category='success')
                return self.redirect('SECURITY_POST_LOGIN_REDIRECT_ENDPOINT')
        else:
            # FIXME-identity
            identity_attrs = app.config.SECURITY_USER_IDENTITY_ATTRIBUTES
            msg = f"Invalid {', '.join(identity_attrs)} and/or password."

            # we just want a single top-level form error
            form._errors = {'_error': [msg]}
            for field in form._fields.values():
                field.errors = None

        if form.errors and request.is_json:
            return self.jsonify({'error': form.errors.get('_error')[0]},
                                code=HTTPStatus.UNAUTHORIZED)

        return self.render('login',
                           login_user_form=form,
                           **self.security.run_ctx_processor('login'))
1107217
def user_login(self, email=None, password=None):
        
        email = six.moves.input("Email: ") if email is None else email
        password = getpass.getpass() if password is None else password

        login_data = {
            "method": "user.login",
            "params": {"email": email,
                       "pass": password}
        }
        # If the user/password match, the server respond will contain a
        #  session cookie that you can use to authenticate future requests.
        r = self.session.post(
            self.base_api_urls["logic"],
            data=json.dumps(login_data),
        )
        if r.json()["result"] not in ["OK"]:
            raise AuthenticationError("Could not authenticate.\n{}"
                                      .format(r.json()))
1283482
def bind(self, database):
        
        self._database = database

        while not self._sessions.full():
            session = self._new_session()
            session.create()
            self._sessions.put(session)
362142
def basic_register(username, password, password2):
    
    if password != password2:
        raise InvalidInput(password={'message': "Passwords do not match"},
                           username={'value': username})
    user = User.objects.create_user(username, password)
    return create_session(user.username, password)
763117
def get_session():
    
    if hasattr(g, 'session'):
        return g.session
    sess = create_session(bind=current_app.config['DATABASE_ENGINE'])
    try:
        g.session = sess
    except RuntimeError:
        pass
    return sess
829376
def POST(self):
        
        if self.user_manager.session_logged_in() or not self.app.allow_registration:
            raise web.notfound()

        reset = None
        msg = ""
        error = False
        data = web.input()
        if "register" in data:
            msg, error = self.register_user(data)
        elif "lostpasswd" in data:
            msg, error = self.lost_passwd(data)
        elif "resetpasswd" in data:
            msg, error, reset = self.get_reset_data(data)
            if reset:
                msg, error = self.reset_passwd(data)
            if not error:
                reset = None

        return self.template_helper.get_renderer().register(reset, msg, error)
421395
private void applyCloseSession(Indexed<CloseSessionEntry> entry) {
    RaftSession session = raft.getSessions().getSession(entry.entry().session());

    // If the server session is null, the session either never existed or already expired.
    if (session == null) {
      throw new RaftException.UnknownSession("Unknown session: " + entry.entry().session());
    }

    RaftServiceContext service = session.getService();
    service.closeSession(entry.index(), entry.entry().timestamp(), session, entry.entry().expired());

    // If this is a delete, unregister the service.
    if (entry.entry().delete()) {
      raft.getServices().unregisterService(service);
      service.close();
    }
  }
571713
def sign_in(controller, record, *args)
      integrate_with_devise_trackable!(controller)

      controller.send(:sign_in, record, *args)
    end
734441
def get_login(self, use_session=True):
        
        # Should we try and return an existing login session?
        if use_session and self._login.check():
            self.cookiejar = self._login.cookiejar
            return self.cookiejar

        # Prompt the user for their login credentials
        username = click.prompt('IPS Username')
        password = click.prompt('IPS Password', hide_input=True)
        remember = click.confirm('Save login session?', True)

        # Process the login
        cookiejar = self._login.process(username, password, remember)
        if remember:
            self.cookiejar = cookiejar

        return cookiejar
699781
def request_sign_out(self, session=requests):
        
        if logout_allowed(self.service):
            request = SingleSignOutRequest(context={'ticket': self})
            url = get_logout_url(self.service) or self.service
            session.post(url, data={'logoutRequest': request.render_content()})
            logger.info("Single sign-out request sent to %s" % url)
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
231818
def _make_login(self):
        
        login_url = '{}data/v1/session/login?user={}&pass={}&sid={}'.format(self.base_url, self.username, self.password,
                                                                            self._parse_session_id(self._session_info))
        self._session_info = get_json(login_url)
101406
def login_listener(app, user):
    
    @after_this_request
    def add_user_session(response):
        """Regenerate current session and add to the SessionActivity table.

        .. note:: `flask.session.regenerate()` actually calls Flask-KVSession's
            `flask_kvsession.KVSession.regenerate`.
        """
        # Regenerate the session to avoid session fixation vulnerabilities.
        session.regenerate()
        # Save the session first so that the sid_s gets generated.
        app.session_interface.save_session(app, session, response)
        add_session(session)
        current_accounts.datastore.commit()
        return response
640153
def login(self):
        """"""
        response = self.session.get(self.signin_url, verify=False)
        user_param, password_param = self._get_hashed_params(response.text)
        login_data = {
            user_param: self.config['username'],
            password_param: self.config['password'],
            'once': self._get_once(response.text),
            'next': '/'
        }
        headers = {'Referer': 'https://www.v2ex.com/signin'}
        self.session.post(self.signin_url, headers=headers, data=login_data)
1142803
def sign_in(who = :user)
      user = if who.instance_of?(User)
               who
             else
               FactoryGirl.build(:user).tap(&:save!)
             end
      visit new_user_session_path
      fill_in 'Email', with: user.email
      fill_in 'Password', with: user.password
      click_button 'Log in'
      expect(page).not_to have_text 'Invalid email or password.'
    end
1004551
def login(user, &block)
      authenticate_session.login user, &block

      if logged_in? && Authenticate.configuration.rotate_csrf_on_sign_in?
        session.delete(:_csrf_token)
        form_authenticity_token
      end
    end