Ejemplo n.º 1
0
 def get(self, request, *args, **kwargs):
     deny_path = request.GET.get("path", "")
     next_page = request.GET.get("next", "/")
     deny_path_list = ["/", "/ticket", "/bill", "/terminal", "/message"]
     if next_page in deny_path_list:
         next_page = "/devops"
     return render_to_response("permission_deny/permission_deny.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 2
0
 def get(self, request, key, *args, **kwargs):
     try:
         key = force_text(urlsafe_base64_decode(key))
         if key != request.session.session_key:
             raise TypeError
     except (TypeError, ValueError, OverflowError):
         messages.error(request, u"会话已过期或无效链接")
         return HttpResponseRedirect("/login")
     cell_phone = request.session.get("password_reset_phone", "")
     return render_to_response("password/password_reset_phone.html",
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 3
0
 def get(self, request, key, *args, **kwargs):
     try:
         key = force_text(urlsafe_base64_decode(key))
         if key != request.session.session_key:
             raise TypeError
     except (TypeError, ValueError, OverflowError):
         messages.error(request, u"会话已过期或无效链接")
         return HttpResponseRedirect("/login")
     email = request.session.get("register_email", "")
     email_link = get_email_link(email)
     return render_to_response("activate/activate_account_done.html",
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 4
0
    def post(self, request, key, *args, **kwargs):
        try:
            key = force_text(urlsafe_base64_decode(key))
            if key != request.session.session_key:
                raise TypeError
        except (TypeError, ValueError, OverflowError):
            messages.error(request, u"会话已过期或无效链接")
            return HttpResponseRedirect("/login")
        if not is_time_up(
                request.session.get("password_reset_email_next_send_datetime",
                                    0)):
            remain_seconds = get_remain_seconds(
                request.session.get("password_reset_email_next_send_datetime",
                                    0))
            messages.error(request, u"发送太频繁,请稍等%s秒再试" % remain_seconds)
            return HttpResponseRedirect("")
        email = request.session.get("reset_password_email", "")
        user = get_user_model().objects.get(accounts__email__iexact=email,
                                            accounts__is_active=True)
        host_name = settings.HOST_NAME
        token_generator = PasswordResetTokenGenerator()
        use_https = request.is_secure()
        context = {
            'email': email,
            'host_name': host_name,
            'uid': urlsafe_base64_encode(force_bytes(user.pk)),
            'token': token_generator.make_token(user),
            'protocol': 'https' if use_https else 'http',
        }
        reset_password_link = "{protocol}://{host_name}/password/reset/confirm/" \
                              "{uid}/{token}".format(**context)
        context_data = {"reset_password_link": reset_password_link}
        email_string = render_to_string("password/password_reset_email.html",
                                        context_instance=RequestContext(
                                            request, context_data))
        request.session["reset_password_email"] = email

        send_auth_email(email_type="password_reset",
                        email=email,
                        html_msg=email_string)

        request.session[
            "password_reset_email_next_send_datetime"] = get_expire_timestamp(
                settings.EMAIL_SEND_INTERVAL)

        return HttpResponseRedirect("")
Ejemplo n.º 5
0
    def post(self, request, *args, **kwargs):
        password_reset_form = PasswordResetForm(request.POST)
        if password_reset_form.is_valid():
            cleaned_data = password_reset_form.clean()
            id_type, identifier = cleaned_data["identifier"]
            url_gid = urlsafe_base64_encode(
                force_bytes(request.session.session_key))

            if id_type == "email":
                email = identifier
                user = get_user_model().objects.get(
                    accounts__email__iexact=email, accounts__is_active=True)
                host_name = settings.HOST_NAME
                token_generator = PasswordResetTokenGenerator()
                use_https = request.is_secure()
                context = {
                    'email': email,
                    'host_name': host_name,
                    'uid': urlsafe_base64_encode(force_bytes(user.pk)),
                    'token': token_generator.make_token(user),
                    'protocol': 'https' if use_https else 'http',
                }
                reset_password_link = "{protocol}://{host_name}/password/reset/confirm/" \
                                      "{uid}/{token}".format(**context)
                context_data = {"reset_password_link": reset_password_link}
                email_string = render_to_string(
                    "password/password_reset_email.html",
                    context_instance=RequestContext(request, context_data))
                request.session["reset_password_email"] = email
                send_auth_email(email_type="password_reset",
                                email=email,
                                html_msg=email_string)
            else:
                cell_phone = identifier
                request.session["password_reset_phone"] = cell_phone
                return HttpResponseRedirect("/password/reset/phone/%s" %
                                            url_gid)
        else:
            error = get_form_error(password_reset_form.errors)
            logger.error(error)
            return HttpResponseRedirect("")

        redirect_link = "/password/reset/done/%s" % url_gid
        return HttpResponseRedirect(redirect_link)
Ejemplo n.º 6
0
    def get(self, request, *args, **kwargs):

        redirect_to = request.GET.get("next", "/")
        request.session["redirect_to"] = redirect_to

        pre_identifier = request.session.get("pre_identifier")
        pre_cell_phone = request.session.get("pre_cell_phone")

        if request.user.is_authenticated() and AccountService.get_by_user(
                user=request.user):
            return HttpResponseRedirect("/")

        request.session["login_tries"] = request.session.get(
            "login_tries") or 0
        show_captcha = (request.session["login_tries"] >=
                        settings.LOGIN_MAX_TRIES)
        return render_to_response('login.html',
                                  context_instance=RequestContext(
                                      request, locals()))
Ejemplo n.º 7
0
 def get(self, request, uidb64, token, *args, **kwargs):
     UserModel = get_user_model()
     token_generator = PasswordResetTokenGenerator()
     try:
         uid = force_text(urlsafe_base64_decode(uidb64))
         user = UserModel.objects.get(pk=uid)
     except (TypeError, ValueError, OverflowError, UserModel.DoesNotExist):
         user = None
     if user is not None and token_generator.check_token(user=user,
                                                         token=token):
         valid_link = True
         title = _(u"重置密码成功")
         msg = _(u"重置链接校验成功")
     else:
         valid_link = False
         title = _(u"重置密码失败")
         msg = _(u"重置链接校验失败,请确认重置密码链接是否正确")
     return render_to_response("password/password_reset_confirm.html",
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 8
0
 def get(self, request, *args, **kwargs):
     page_name = "router_detail"
     return render_to_response(self.template,
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 9
0
 def get(self, request, *args, **kwargs):
     captcha_key = CaptchaStore.generate_key()
     captcha_image = captcha_image_url(captcha_key)
     return render_to_response('password/password_reset.html',
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 10
0
 def get(self, request, *args, **kwargs):
     return render_to_response("ServiceCenter/serviceCenter.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 11
0
 def get(self, request, *args, **kwargs):
     page_name = "customize_flavor"
     return render_to_response(self.template,
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 12
0
 def get(self, request, *args, **kwargs):
     return render_to_response('register/register.html',
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 13
0
 def get(self, request, *args, **kwargs):
     page_name = 'dashboard'
     return render_to_response('dashboard.html',
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 14
0
 def get(self, request, page='info', *args, **kwargs):
     page_name = "config_advanced"
     return render_to_response('setting/advanced_config.html',
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 15
0
 def get(self, request, *args, **kwargs):
     return render_to_response("financeIndex/financeCloud.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 16
0
 def get(self, request, *args, **kwargs):
     return render_to_response("UserModule/user.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 17
0
 def get(self, request, *args, **kwargs):
     return render_to_response("compatibility/compatibility.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 18
0
 def get(self, request, *args, **kwargs):
     return render_to_response("help_page/help_page.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 19
0
 def get(self, request, *args, **kwargs):
     return render_to_response("password/password_reset_complete.html",
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 20
0
 def get(self, request, *args, **kwargs):
     return render_to_response("tenant_dashboard.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 21
0
 def get(self, request, *args, **kwargs):
     activate_link = """http://127.0.0.1:9000/register/complete/bGlhb3FpbmNoYW9AY2xvdWRpbi5yZW4/494a9c5071db499f9a4\
     8098a748412236a71e65ac79842a994fc1e260ea4269e2ef81720a0b043fbae6a5a8c48650de2"""
     return render_to_response("password/password_reset_email.html",
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 22
0
 def get(self, request, *args, **kwargs):
     return render_to_response("screen/screen.html",
                               context_instance=RequestContext(request, locals()))
Ejemplo n.º 23
0
 def get(self, request, *args, **kwargs):
     page_name = "sourceManage_topSpeed"
     return render_to_response(self.template,
                               context_instance=RequestContext(
                                   request, locals()))
Ejemplo n.º 24
0
 def post(self, request, *args, **kwargs):
     action = request.POST.get("action")
     if action == 'logo':
         PlatformSettings.change_logo_image(request, *args, **kwargs)
     return render_to_response("backstageModule/backstage.html",
                               context_instance=RequestContext(request, locals()))