

"""simple docstring"""
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available


_A						=     {}

try:
    if not is_sentencepiece_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A						=     ['CpmTokenizer']

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A						=     ['CpmTokenizerFast']


if TYPE_CHECKING:
    try:
        if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_cpm import CpmTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_cpm_fast import CpmTokenizerFast

else:
    import sys

    _A						=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




"""simple docstring"""
import requests

try:
    from django.contrib.auth import authenticate, login
    from django.shortcuts import redirect, render
except ImportError:
    _A						=     _A						=     _A						=     _A						=     print




def 				a__	(	lowerCAmelCase						)  ->   str:
      # Enter your recaptcha secret key here
      UpperCAmelCase__ :       int						=						"""secretKey"""
      UpperCAmelCase__ :       Any						=						"""https://www.google.com/recaptcha/api/siteverify"""

      # when method is not POST, direct user to login page
      if request.method != "POST":
            return render(lowerCAmelCase ,  """login.html"""						)

      # from the frontend, get username, password, and client_key
      UpperCAmelCase__ :       List[Any]						=						request.POST.get("""username"""						)
      UpperCAmelCase__ :       Optional[Any]						=						request.POST.get("""password"""						)
      UpperCAmelCase__ :       List[str]						=						request.POST.get("""g-recaptcha-response"""						)

      # post recaptcha response to Google's recaptcha api
      UpperCAmelCase__ :       Any						=						requests.post(lowerCAmelCase ,  data={"""secret""": secret_key, """response""": client_key}						)
      # if the recaptcha api verified our keys
      if response.json().get("""success""" ,  lowerCAmelCase						):
            # authenticate the user
            UpperCAmelCase__ :       List[str]						=						authenticate(lowerCAmelCase ,  username=lowerCAmelCase ,  password=lowerCAmelCase						)
            if user_in_database:
                  login(lowerCAmelCase ,  lowerCAmelCase						)
                  return redirect("""/your-webpage"""						)
      return render(lowerCAmelCase ,  """login.html"""						)

