Commit ed56c71ba18f995c934afc74b06c44e6d0a2fe35
Merge remote-tracking branch 'origin/feature/1.8.0-uniapp' into feature/1.8.0-uniapp
Showing
11 changed files
with
75 additions
and
137 deletions
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
| ... | ... | @@ -141,23 +141,16 @@ public class AuthController { |
| 141 | 141 | @ApiImplicitParam(name = "type", value = "社交类型", required = true, dataTypeClass = Integer.class), |
| 142 | 142 | @ApiImplicitParam(name = "redirectUri", value = "回调路径", dataTypeClass = String.class) |
| 143 | 143 | }) |
| 144 | - public CommonResult<String> socialAuthRedirect(@RequestParam("type") Integer type, | |
| 144 | + public CommonResult<String> socialLogin(@RequestParam("type") Integer type, | |
| 145 | 145 | @RequestParam("redirectUri") String redirectUri) { |
| 146 | 146 | return CommonResult.success(socialUserService.getAuthorizeUrl(type, redirectUri)); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - @PostMapping("/social-quick-login") | |
| 150 | - @ApiOperation("社交快捷登录,使用 code 授权码") | |
| 149 | + @PostMapping("/social-login") | |
| 150 | + @ApiOperation(value = "社交快捷登录,使用 code 授权码", notes = "适合未登录的用户,但是社交账号已绑定用户") | |
| 151 | 151 | @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 |
| 152 | - public CommonResult<AuthLoginRespVO> socialQuickLogin(@RequestBody @Valid AuthSocialQuickLoginReqVO reqVO) { | |
| 153 | - return success(authService.socialQuickLogin(reqVO)); | |
| 154 | - } | |
| 155 | - | |
| 156 | - @PostMapping("/social-bind-login") | |
| 157 | - @ApiOperation("社交绑定登录,使用 code 授权码 + 账号密码") | |
| 158 | - @OperateLog(enable = false) // 避免 Post 请求被记录操作日志 | |
| 159 | - public CommonResult<AuthLoginRespVO> socialBindLogin(@RequestBody @Valid AuthSocialBindLoginReqVO reqVO) { | |
| 160 | - return success(authService.socialBindLogin(reqVO)); | |
| 152 | + public CommonResult<AuthLoginRespVO> socialQuickLogin(@RequestBody @Valid AuthSocialLoginReqVO reqVO) { | |
| 153 | + return success(authService.socialLogin(reqVO)); | |
| 161 | 154 | } |
| 162 | 155 | |
| 163 | 156 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthLoginReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.admin.auth.vo; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | |
| 3 | 6 | import io.swagger.annotations.ApiModel; |
| 4 | 7 | import io.swagger.annotations.ApiModelProperty; |
| 5 | 8 | import lombok.AllArgsConstructor; |
| ... | ... | @@ -8,10 +11,11 @@ import lombok.Data; |
| 8 | 11 | import lombok.NoArgsConstructor; |
| 9 | 12 | import org.hibernate.validator.constraints.Length; |
| 10 | 13 | |
| 14 | +import javax.validation.constraints.AssertTrue; | |
| 11 | 15 | import javax.validation.constraints.NotEmpty; |
| 12 | 16 | import javax.validation.constraints.Pattern; |
| 13 | 17 | |
| 14 | -@ApiModel("管理后台 - 账号密码登录 Request VO") | |
| 18 | +@ApiModel(value = "管理后台 - 账号密码登录 Request VO", description = "如果登录并绑定社交用户,需要传递 social 开头的参数") | |
| 15 | 19 | @Data |
| 16 | 20 | @NoArgsConstructor |
| 17 | 21 | @AllArgsConstructor |
| ... | ... | @@ -29,6 +33,8 @@ public class AuthLoginReqVO { |
| 29 | 33 | @Length(min = 4, max = 16, message = "密码长度为 4-16 位") |
| 30 | 34 | private String password; |
| 31 | 35 | |
| 36 | + // ========== 图片验证码相关 ========== | |
| 37 | + | |
| 32 | 38 | @ApiModelProperty(value = "验证码", required = true, example = "1024", notes = "验证码开启时,需要传递") |
| 33 | 39 | @NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class) |
| 34 | 40 | private String code; |
| ... | ... | @@ -37,9 +43,31 @@ public class AuthLoginReqVO { |
| 37 | 43 | @NotEmpty(message = "唯一标识不能为空", groups = CodeEnableGroup.class) |
| 38 | 44 | private String uuid; |
| 39 | 45 | |
| 46 | + // ========== 绑定社交登录时,需要传递如下参数 ========== | |
| 47 | + | |
| 48 | + @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值") | |
| 49 | + @InEnum(SocialTypeEnum.class) | |
| 50 | + private Integer socialType; | |
| 51 | + | |
| 52 | + @ApiModelProperty(value = "授权码", required = true, example = "1024") | |
| 53 | + private String socialCode; | |
| 54 | + | |
| 55 | + @ApiModelProperty(value = "state", required = true, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") | |
| 56 | + private String socialState; | |
| 57 | + | |
| 40 | 58 | /** |
| 41 | 59 | * 开启验证码的 Group |
| 42 | 60 | */ |
| 43 | 61 | public interface CodeEnableGroup {} |
| 44 | 62 | |
| 63 | + @AssertTrue(message = "授权码不能为空") | |
| 64 | + public boolean isSocialCodeValid() { | |
| 65 | + return socialType == null || StrUtil.isNotEmpty(socialCode); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @AssertTrue(message = "授权 state 不能为空") | |
| 69 | + public boolean isSocialState() { | |
| 70 | + return socialType == null || StrUtil.isNotEmpty(socialState); | |
| 71 | + } | |
| 72 | + | |
| 45 | 73 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialBindLoginReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.system.controller.admin.auth.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | |
| 5 | -import io.swagger.annotations.ApiModel; | |
| 6 | -import io.swagger.annotations.ApiModelProperty; | |
| 7 | -import lombok.AllArgsConstructor; | |
| 8 | -import lombok.Builder; | |
| 9 | -import lombok.Data; | |
| 10 | -import lombok.NoArgsConstructor; | |
| 11 | -import org.hibernate.validator.constraints.Length; | |
| 12 | - | |
| 13 | -import javax.validation.constraints.NotEmpty; | |
| 14 | -import javax.validation.constraints.NotNull; | |
| 15 | -import javax.validation.constraints.Pattern; | |
| 16 | - | |
| 17 | -@ApiModel("管理后台 - 社交绑定登录 Request VO,使用 code 授权码 + 账号密码") | |
| 18 | -@Data | |
| 19 | -@NoArgsConstructor | |
| 20 | -@AllArgsConstructor | |
| 21 | -@Builder | |
| 22 | -public class AuthSocialBindLoginReqVO { | |
| 23 | - | |
| 24 | - @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 UserSocialTypeEnum 枚举值") | |
| 25 | - @InEnum(SocialTypeEnum.class) | |
| 26 | - @NotNull(message = "社交平台的类型不能为空") | |
| 27 | - private Integer type; | |
| 28 | - | |
| 29 | - @ApiModelProperty(value = "授权码", required = true, example = "1024") | |
| 30 | - @NotEmpty(message = "授权码不能为空") | |
| 31 | - private String code; | |
| 32 | - | |
| 33 | - @ApiModelProperty(value = "state", required = true, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") | |
| 34 | - @NotEmpty(message = "state 不能为空") | |
| 35 | - private String state; | |
| 36 | - | |
| 37 | - @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") | |
| 38 | - @NotEmpty(message = "登录账号不能为空") | |
| 39 | - @Length(min = 4, max = 16, message = "账号长度为 4-16 位") | |
| 40 | - @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") | |
| 41 | - private String username; | |
| 42 | - | |
| 43 | - @ApiModelProperty(value = "密码", required = true, example = "buzhidao") | |
| 44 | - @NotEmpty(message = "密码不能为空") | |
| 45 | - @Length(min = 4, max = 16, message = "密码长度为 4-16 位") | |
| 46 | - private String password; | |
| 47 | - | |
| 48 | -} |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialQuickLoginReqVO.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/vo/AuthSocialLoginReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.admin.auth.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | +import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; | |
| 5 | 5 | import io.swagger.annotations.ApiModel; |
| 6 | 6 | import io.swagger.annotations.ApiModelProperty; |
| 7 | 7 | import lombok.AllArgsConstructor; |
| ... | ... | @@ -12,12 +12,12 @@ import lombok.NoArgsConstructor; |
| 12 | 12 | import javax.validation.constraints.NotEmpty; |
| 13 | 13 | import javax.validation.constraints.NotNull; |
| 14 | 14 | |
| 15 | -@ApiModel("管理后台 - 社交快捷登录 Request VO,使用 code 授权码") | |
| 15 | +@ApiModel("管理后台 - 社交绑定登录 Request VO,使用 code 授权码 + 账号密码") | |
| 16 | 16 | @Data |
| 17 | 17 | @NoArgsConstructor |
| 18 | 18 | @AllArgsConstructor |
| 19 | 19 | @Builder |
| 20 | -public class AuthSocialQuickLoginReqVO { | |
| 20 | +public class AuthSocialLoginReqVO { | |
| 21 | 21 | |
| 22 | 22 | @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 UserSocialTypeEnum 枚举值") |
| 23 | 23 | @InEnum(SocialTypeEnum.class) | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java
| ... | ... | @@ -65,8 +65,7 @@ public interface AuthConvert { |
| 65 | 65 | return CollectionUtils.filterList(treeNodeMap.values(), node -> MenuIdEnum.ROOT.getId().equals(node.getParentId())); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - SocialUserBindReqDTO convert(Long userId, Integer userType, AuthSocialBindLoginReqVO reqVO); | |
| 69 | - SocialUserBindReqDTO convert(Long userId, Integer userType, AuthSocialQuickLoginReqVO reqVO); | |
| 68 | + SocialUserBindReqDTO convert(Long userId, Integer userType, AuthSocialLoginReqVO reqVO); | |
| 70 | 69 | |
| 71 | 70 | SmsCodeSendReqDTO convert(AuthSmsSendReqVO reqVO); |
| 72 | 71 | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java
| ... | ... | @@ -24,8 +24,7 @@ public class SecurityConfiguration { |
| 24 | 24 | registry.antMatchers(buildAdminApi("/system/auth/refresh-token")).permitAll(); |
| 25 | 25 | // 社交登陆的接口 |
| 26 | 26 | registry.antMatchers(buildAdminApi("/system/auth/social-auth-redirect")).permitAll(); |
| 27 | - registry.antMatchers(buildAdminApi("/system/auth/social-quick-login")).permitAll(); | |
| 28 | - registry.antMatchers(buildAdminApi("/system/auth/social-bind-login")).permitAll(); | |
| 27 | + registry.antMatchers(buildAdminApi("/system/auth/social-login")).permitAll(); | |
| 29 | 28 | // 登录登录的接口 |
| 30 | 29 | registry.antMatchers(buildAdminApi("/system/auth/sms-login")).permitAll(); |
| 31 | 30 | registry.antMatchers(buildAdminApi("/system/auth/send-sms-code")).permitAll(); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java
| ... | ... | @@ -60,15 +60,7 @@ public interface AdminAuthService { |
| 60 | 60 | * @param reqVO 登录信息 |
| 61 | 61 | * @return 登录结果 |
| 62 | 62 | */ |
| 63 | - AuthLoginRespVO socialQuickLogin(@Valid AuthSocialQuickLoginReqVO reqVO); | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * 社交绑定登录,使用 code 授权码 + 账号密码 | |
| 67 | - * | |
| 68 | - * @param reqVO 登录信息 | |
| 69 | - * @return 登录结果 | |
| 70 | - */ | |
| 71 | - AuthLoginRespVO socialBindLogin(@Valid AuthSocialBindLoginReqVO reqVO); | |
| 63 | + AuthLoginRespVO socialLogin(@Valid AuthSocialLoginReqVO reqVO); | |
| 72 | 64 | |
| 73 | 65 | /** |
| 74 | 66 | * 刷新访问令牌 | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
| ... | ... | @@ -8,13 +8,14 @@ import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 9 | 9 | import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; |
| 10 | 10 | import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; |
| 11 | +import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; | |
| 11 | 12 | import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; |
| 12 | 13 | import cn.iocoder.yudao.module.system.convert.auth.AuthConvert; |
| 13 | 14 | import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; |
| 14 | 15 | import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; |
| 15 | -import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants; | |
| 16 | 16 | import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; |
| 17 | 17 | import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; |
| 18 | +import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants; | |
| 18 | 19 | import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; |
| 19 | 20 | import cn.iocoder.yudao.module.system.service.common.CaptchaService; |
| 20 | 21 | import cn.iocoder.yudao.module.system.service.logger.LoginLogService; |
| ... | ... | @@ -91,6 +92,12 @@ public class AdminAuthServiceImpl implements AdminAuthService { |
| 91 | 92 | // 使用账号密码,进行登录 |
| 92 | 93 | AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword()); |
| 93 | 94 | |
| 95 | + // 如果 socialType 非空,说明需要绑定社交用户 | |
| 96 | + if (reqVO.getSocialType() != null) { | |
| 97 | + socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), | |
| 98 | + reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); | |
| 99 | + } | |
| 100 | + | |
| 94 | 101 | // 创建 Token 令牌,记录登录日志 |
| 95 | 102 | return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME); |
| 96 | 103 | } |
| ... | ... | @@ -166,7 +173,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { |
| 166 | 173 | } |
| 167 | 174 | |
| 168 | 175 | @Override |
| 169 | - public AuthLoginRespVO socialQuickLogin(AuthSocialQuickLoginReqVO reqVO) { | |
| 176 | + public AuthLoginRespVO socialLogin(AuthSocialLoginReqVO reqVO) { | |
| 170 | 177 | // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号 |
| 171 | 178 | Long userId = socialUserService.getBindUserId(UserTypeEnum.ADMIN.getValue(), reqVO.getType(), |
| 172 | 179 | reqVO.getCode(), reqVO.getState()); |
| ... | ... | @@ -185,18 +192,6 @@ public class AdminAuthServiceImpl implements AdminAuthService { |
| 185 | 192 | } |
| 186 | 193 | |
| 187 | 194 | @Override |
| 188 | - public AuthLoginRespVO socialBindLogin(AuthSocialBindLoginReqVO reqVO) { | |
| 189 | - // 使用账号密码,进行登录。 | |
| 190 | - AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword()); | |
| 191 | - | |
| 192 | - // 绑定社交用户 | |
| 193 | - socialUserService.bindSocialUser(AuthConvert.INSTANCE.convert(user.getId(), getUserType().getValue(), reqVO)); | |
| 194 | - | |
| 195 | - // 创建 Token 令牌,记录登录日志 | |
| 196 | - return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL); | |
| 197 | - } | |
| 198 | - | |
| 199 | - @Override | |
| 200 | 195 | public AuthLoginRespVO refreshToken(String refreshToken) { |
| 201 | 196 | OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, OAuth2ClientConstants.CLIENT_ID_DEFAULT); |
| 202 | 197 | return AuthConvert.INSTANCE.convert(accessTokenDO); | ... | ... |
yudao-ui-admin/src/api/login.js
| ... | ... | @@ -3,12 +3,15 @@ import {getRefreshToken} from "@/utils/auth"; |
| 3 | 3 | import service from "@/utils/request"; |
| 4 | 4 | |
| 5 | 5 | // 登录方法 |
| 6 | -export function login(username, password, code, uuid) { | |
| 6 | +export function login(username, password, code, uuid, | |
| 7 | + socialType, socialCode, socialState) { | |
| 7 | 8 | const data = { |
| 8 | 9 | username, |
| 9 | 10 | password, |
| 10 | 11 | code, |
| 11 | - uuid | |
| 12 | + uuid, | |
| 13 | + // 社交相关 | |
| 14 | + socialType, socialCode, socialState | |
| 12 | 15 | } |
| 13 | 16 | return request({ |
| 14 | 17 | url: '/system/auth/login', |
| ... | ... | @@ -51,9 +54,9 @@ export function socialAuthRedirect(type, redirectUri) { |
| 51 | 54 | } |
| 52 | 55 | |
| 53 | 56 | // 社交快捷登录,使用 code 授权码 |
| 54 | -export function socialQuickLogin(type, code, state) { | |
| 57 | +export function socialLogin(type, code, state) { | |
| 55 | 58 | return request({ |
| 56 | - url: '/system/auth/social-quick-login', | |
| 59 | + url: '/system/auth/social-login', | |
| 57 | 60 | method: 'post', |
| 58 | 61 | data: { |
| 59 | 62 | type, |
| ... | ... | @@ -63,21 +66,6 @@ export function socialQuickLogin(type, code, state) { |
| 63 | 66 | }) |
| 64 | 67 | } |
| 65 | 68 | |
| 66 | -// 社交绑定登录,使用 code 授权码 + + 账号密码 | |
| 67 | -export function socialBindLogin(type, code, state, username, password) { | |
| 68 | - return request({ | |
| 69 | - url: '/system/auth/social-bind-login', | |
| 70 | - method: 'post', | |
| 71 | - data: { | |
| 72 | - type, | |
| 73 | - code, | |
| 74 | - state, | |
| 75 | - username, | |
| 76 | - password | |
| 77 | - } | |
| 78 | - }) | |
| 79 | -} | |
| 80 | - | |
| 81 | 69 | // 获取登录验证码 |
| 82 | 70 | export function sendSmsCode(mobile, scene) { |
| 83 | 71 | return request({ | ... | ... |
yudao-ui-admin/src/store/modules/user.js
| 1 | -import {login, logout, getInfo, socialQuickLogin, socialBindLogin, smsLogin} from '@/api/login' | |
| 1 | +import {login, logout, getInfo, socialLogin, socialBindLogin, smsLogin} from '@/api/login' | |
| 2 | 2 | import {getAccessToken, setToken, removeToken, getRefreshToken} from '@/utils/auth' |
| 3 | 3 | |
| 4 | 4 | const user = { |
| ... | ... | @@ -38,8 +38,12 @@ const user = { |
| 38 | 38 | const password = userInfo.password |
| 39 | 39 | const code = userInfo.code |
| 40 | 40 | const uuid = userInfo.uuid |
| 41 | + const socialCode = userInfo.socialCode | |
| 42 | + const socialState = userInfo.socialState | |
| 43 | + const socialType = userInfo.socialType | |
| 41 | 44 | return new Promise((resolve, reject) => { |
| 42 | - login(username, password, code, uuid).then(res => { | |
| 45 | + login(username, password, code, uuid, | |
| 46 | + socialType, socialCode, socialState).then(res => { | |
| 43 | 47 | res = res.data; |
| 44 | 48 | // 设置 token |
| 45 | 49 | setToken(res) |
| ... | ... | @@ -56,7 +60,7 @@ const user = { |
| 56 | 60 | const state = userInfo.state |
| 57 | 61 | const type = userInfo.type |
| 58 | 62 | return new Promise((resolve, reject) => { |
| 59 | - socialQuickLogin(type, code, state).then(res => { | |
| 63 | + socialLogin(type, code, state).then(res => { | |
| 60 | 64 | res = res.data; |
| 61 | 65 | // 设置 token |
| 62 | 66 | setToken(res) |
| ... | ... | @@ -67,25 +71,7 @@ const user = { |
| 67 | 71 | }) |
| 68 | 72 | }, |
| 69 | 73 | |
| 70 | - // 社交登录 | |
| 71 | - SocialLogin2({ commit }, userInfo) { | |
| 72 | - const code = userInfo.code | |
| 73 | - const state = userInfo.state | |
| 74 | - const type = userInfo.type | |
| 75 | - const username = userInfo.username.trim() | |
| 76 | - const password = userInfo.password | |
| 77 | - return new Promise((resolve, reject) => { | |
| 78 | - socialBindLogin(type, code, state, username, password).then(res => { | |
| 79 | - res = res.data; | |
| 80 | - // 设置 token | |
| 81 | - setToken(res) | |
| 82 | - resolve() | |
| 83 | - }).catch(error => { | |
| 84 | - reject(error) | |
| 85 | - }) | |
| 86 | - }) | |
| 87 | - }, | |
| 88 | - // 登录 | |
| 74 | + // 短信登录 | |
| 89 | 75 | SmsLogin({ commit }, userInfo) { |
| 90 | 76 | const mobile = userInfo.mobile.trim() |
| 91 | 77 | const mobileCode = userInfo.mobileCode | ... | ... |
yudao-ui-admin/src/views/socialLogin.vue
| ... | ... | @@ -87,6 +87,8 @@ export default { |
| 87 | 87 | username: "admin", |
| 88 | 88 | password: "admin123", |
| 89 | 89 | rememberMe: false, |
| 90 | + code: "", | |
| 91 | + uuid: "", | |
| 90 | 92 | }, |
| 91 | 93 | loginRules: { |
| 92 | 94 | username: [ |
| ... | ... | @@ -170,16 +172,20 @@ export default { |
| 170 | 172 | removeUsername() |
| 171 | 173 | removePassword() |
| 172 | 174 | } |
| 173 | - this.$store.dispatch("SocialLogin2", { | |
| 174 | - code: this.code, | |
| 175 | - state: this.state, | |
| 176 | - type: this.type, | |
| 175 | + this.$store.dispatch("Login", { | |
| 176 | + socialCode: this.code, | |
| 177 | + socialState: this.state, | |
| 178 | + socialType: this.type, | |
| 179 | + // 账号密码登录 | |
| 177 | 180 | username: this.loginForm.username, |
| 178 | - password: this.loginForm.password | |
| 181 | + password: this.loginForm.password, | |
| 182 | + code: this.loginForm.code, | |
| 183 | + uuid: this.loginForm.uuid, | |
| 179 | 184 | }).then(() => { |
| 180 | 185 | this.$router.push({ path: this.redirect || "/" }).catch(()=>{}); |
| 181 | 186 | }).catch(() => { |
| 182 | 187 | this.loading = false; |
| 188 | + this.getCode() | |
| 183 | 189 | }); |
| 184 | 190 | } |
| 185 | 191 | }); | ... | ... |