Sin Descripción

preauth_views.py 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. from __future__ import division
  3. from django.conf import settings
  4. from django.shortcuts import render
  5. from pywe_component import get_pre_auth_url
  6. from pywe_component_preauthcode import component_preauthcode
  7. from pywe_storage import RedisStorage
  8. from utils.redis.connect import r
  9. COMPONENT = settings.WECHAT.get('COMPONENT', {})
  10. def preauth(request):
  11. return render(request, 'page/preauth/preauth.html', {
  12. 'domain': settings.DOMAIN,
  13. 'preauthurl': settings.DJANGO_DEBUG_PREAUTHURL or get_pre_auth_url(
  14. COMPONENT.get('appID'),
  15. pre_auth_code=component_preauthcode(appid=COMPONENT['appID'], secret=COMPONENT['appsecret'], storage=RedisStorage(r)),
  16. redirect_uri=settings.DJANGO_WE_COMPONENT_REDIRECT_URI,
  17. auth_type=3,
  18. mobi=request.weixin,
  19. ),
  20. })
  21. def preauth_success(request):
  22. return render(request, 'page/preauth/preauth_success.html', {
  23. 'domain': settings.DOMAIN,
  24. 'authorizer_appid': settings.DJANGO_DEBUG_AUTHORIZER_APPID,
  25. })