<commit_before># -*- coding: utf-8 -*-

"""
Kay authentication views.

:Copyright: (c) 2009 Accense Technology, Inc. 
                     <NAME> <<EMAIL>>,
                     All rights reserved.
:license: BSD, see LICENSE for more details.
"""

from urllib import unquote_plus

from werkzeug import (
  unescape, redirect, Response,
)
from werkzeug.urls import url_encode
from werkzeug.utils import import_string
from werkzeug.exceptions import Forbidden

from kay.utils import (
  local, render_to_response, url_for,
)
from kay.utils import flash
from kay.i18n import lazy_gettext as _
from kay.i18n import gettext
from kay.cache.decorators import no_cache
from kay.cache import NoCacheMixin
from kay.handlers import BaseHandler
from kay.conf import settings

from kay.auth.forms import (
  LoginForm, ChangePasswordForm, ResetPasswordRequestForm, ResetPasswordForm,
  LoginBoxForm,
)
from kay.auth.models import TemporarySession

def post_session(request):
  if request.method == "GET":
    from models import TemporarySession
    temporary_session = TemporarySession.get_by_key_name(
      request.values.get("session_id"))
    if temporary_session is not None:
      temporary_session.delete()
      import datetime
      allowed_datetime = datetime.datetime.now() - \
          datetime.timedelta(seconds=10)
      if temporary_session.created > allowed_datetime:
        from kay.sessions import renew_session
        renew_session(request)
        request.session['_user'] = temporary_session.user.key()
        return redirect(unquote_plus(request.values.get('next')))
  return Response("Error")

@no_cache
def login(request):
  from kay.auth import login

  next = unquote_plus(request.values.get("next"))
  owned_domain_hack = request.values.get("owned_domain_hack")
  message = ""
  form = LoginForm()
  if request.method == "POST":
    if form.validate(request.form):
      result = login(request, user_name=form.data['user_name'],
                              password=form.data['password'])
      if result:
        if owned_domain_hack == 'True':<commit_msg>Supplied a default value.<commit_after># -*- coding: utf-8 -*-

"""
Kay authentication views.

:Copyright: (c) 2009 Accense Technology, Inc. 
                     <NAME> <<EMAIL>>,
                     All rights reserved.
:license: BSD, see LICENSE for more details.
"""

from urllib import unquote_plus

from werkzeug import (
  unescape, redirect, Response,
)
from werkzeug.urls import url_encode
from werkzeug.utils import import_string
from werkzeug.exceptions import Forbidden

from kay.utils import (
  local, render_to_response, url_for,
)
from kay.utils import flash
from kay.i18n import lazy_gettext as _
from kay.i18n import gettext
from kay.cache.decorators import no_cache
from kay.cache import NoCacheMixin
from kay.handlers import BaseHandler
from kay.conf import settings

from kay.auth.forms import (
  LoginForm, ChangePasswordForm, ResetPasswordRequestForm, ResetPasswordForm,
  LoginBoxForm,
)
from kay.auth.models import TemporarySession

def post_session(request):
  if request.method == "GET":
    from models import TemporarySession
    temporary_session = TemporarySession.get_by_key_name(
      request.values.get("session_id"))
    if temporary_session is not None:
      temporary_session.delete()
      import datetime
      allowed_datetime = datetime.datetime.now() - \
          datetime.timedelta(seconds=10)
      if temporary_session.created > allowed_datetime:
        from kay.sessions import renew_session
        renew_session(request)
        request.session['_user'] = temporary_session.user.key()
        return redirect(unquote_plus(request.values.get('next')))
  return Response("Error")

@no_cache
def login(request):
  from kay.auth import login

  next = unquote_plus(request.values.get("next", "/"))
  owned_domain_hack = request.values.get("owned_domain_hack")
  message = ""
  form = LoginForm()
  if request.method == "POST":
    if form.validate(request.form):
      result = login(request, user_name=form.data['user_name'],
                              password=form.data['password'])
      if result:
        if owned_domain_hack == 'True':
{'fraction_non_alphanumeric': 0.09465612269350587, 'fraction_numerical': 0.005271986580397795, 'mean_word_length': 3.6121546961325968, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3258837', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1212, 'n_words': 318}