You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Django/doc/oauth/urls.py

40 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 导入Django的URL路径配置模块
from django.urls import path
# 导入当前应用oauth的视图模块
from . import views
# 定义应用命名空间,用于模板或反向解析时指定应用(如:{% url 'oauth:oauthlogin' %}
app_name = "oauth"
# URL路由配置列表映射URL路径到对应的视图函数/类
urlpatterns = [
# 1. OAuth授权回调接口接收第三方平台返回的授权码code处理后续登录逻辑
path(
r'oauth/authorize',
views.authorize), # 对应视图函数authorize
# 2. 补充邮箱页面:第三方登录时用户未提供邮箱,跳转至此页面补充
path(
r'oauth/requireemail/<int:oauthid>.html', # 路径参数oauthidOAuthUser的ID
views.RequireEmailView.as_view(), # 对应基于类的视图RequireEmailView
name='require_email'), # 路由名称:用于反向解析
# 3. 邮箱确认接口验证用户补充邮箱的有效性通过sign签名验证
path(
r'oauth/emailconfirm/<int:id>/<sign>.html', # 路径参数idOAuthUser的ID、sign验证签名
views.emailconfirm, # 对应视图函数emailconfirm
name='email_confirm'), # 路由名称:用于反向解析
# 4. 绑定成功页面:邮箱补充或账号绑定完成后,展示成功提示
path(
r'oauth/bindsuccess/<int:oauthid>.html', # 路径参数oauthidOAuthUser的ID
views.bindsuccess, # 对应视图函数bindsuccess
name='bindsuccess'), # 路由名称:用于反向解析
# 5. OAuth登录入口生成第三方平台的授权链接跳转至第三方授权页面
path(
r'oauth/oauthlogin',
views.oauthlogin, # 对应视图函数oauthlogin
name='oauthlogin') # 路由名称:用于反向解析
]