跳到主要内容

第三方登录账号绑定API设计

一、PC登录绑定

路径
URL:{passport-domain}/login-binder/PC/{uuid}/
methodPOST
参数
参数类型说明
usernameString用户名
passwordString密码
captchaString图片验证码
uuidString客户端唯一id

处理逻辑

如果用户名密码验证成功,则查看此会员中是否已经绑定了此平台的openid

如果已经绑定,则将此uuid和此用户id及type在redis中建立关系,有效期为5分钟。

并返回:

{
"result":"existed",
"access_token":"xxxx",
"refresh_token":"xxxx"
}

此时前端会弹出提示询问客户是否确认要覆盖,还是选择其它账号

如果选择覆盖,则再调用登录绑定openid api来绑定

如果没有绑定此平台的openid,则将此Openid写入此会员,并返回token:

{
"result":"bind_success",
"access_token":"xxxx",
"refresh_token":"xxxx"
}

失败 :

{
"code":"1001",
"message":"..."
}

###二、登录绑定openid API

路径
URL:{buyer-domain}/account-binder/login/{uuid}
METHODPOST
参数
参数类型说明
uuidString对照过openid的uuid
处理逻辑

由redis中取出对应的type和openid

由usercontext中拿到buyer

将两者在数据库中建立关联

三、注册绑定openid API

路径
路径
URL:{buyer-domain}/account-binder/register/{uuid}
METHODPOST
参数
参数类型说明
uuidString对照过openid的uuid
处理逻辑

由redis中取出对应的type和openid

由usercontext中拿到buyer

将两者在数据库中建立关联

根据uuid得到Auth2Token对象,请求第三方平台获取头像、昵称,更新会员信息

三、WAP绑定

1、发送验证码

路径
URL:{passport-domain}/mobile-binder/WAP/smscode/{mobile}
methodPOST
参数
参数类型说明
uuidString
mobileString要注册的手机号
captchaString图片验证码

处理逻辑

读取相应短信模板(短信验证码登录功能),并发送短信。

将生成的验证码和uuid在redis中进行关联、

2、手机绑定

路径
URL:{passport-domain}/mobile-binder/WAP/{uuid}
methodPOST
参数
参数类型说明
uuidString
mobileString要注册的手机号
codeString短信验证码

处理逻辑

根据uuid得到Auth2Token对象,请求第三方平台获取头像、昵称,并注册为我平台会员

如果此手机号已经绑定账号且未绑定过openid,则进行绑定并返回token:

{
"result":"bind_success",
"access_token":"xxxx",
"refresh_token":"xxxx"
}

如果此手机号已经绑定账号且已经绑定过openid,则返回:

{
"result":"existed",
"access_token":"xxxx",
"refresh_token":"xxxx"
}

前台询问会员是否替换覆盖,同意则调用登录绑定openid api

四、WAP登录绑定

路径
URL:{passport-domain}/login-binder/WAP/{uuid}/
methodPOST

其它同PC登录绑定