Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="UserFriendlyException"></exception>
|
/// <exception cref="UserFriendlyException"></exception>
|
||||||
[HttpGet("auth/oauth/login/{scheme}")]
|
[HttpGet("auth/oauth/login/{scheme}")]
|
||||||
public async Task<string> AuthOauthLoginAsync([FromRoute] string scheme, [FromQuery] string code)
|
public async Task<object> AuthOauthLoginAsync([FromRoute] string scheme, [FromQuery] string code)
|
||||||
{
|
{
|
||||||
(var openId, var _) = await GetOpenIdAndNameAsync(scheme);
|
(var openId, var _) = await GetOpenIdAndNameAsync(scheme);
|
||||||
var authEntity = await _repository.GetAsync(x => x.OpenId == openId && x.AuthType == scheme);
|
var authEntity = await _repository.GetAsync(x => x.OpenId == openId && x.AuthType == scheme);
|
||||||
@@ -50,7 +50,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication
|
|||||||
throw new UserFriendlyException("第三方登录失败,请先注册后,在个人中心进行绑定该第三方后使用");
|
throw new UserFriendlyException("第三方登录失败,请先注册后,在个人中心进行绑定该第三方后使用");
|
||||||
}
|
}
|
||||||
var accessToken = await _accountManager.GetTokenByUserIdAsync(authEntity.UserId);
|
var accessToken = await _accountManager.GetTokenByUserIdAsync(authEntity.UserId);
|
||||||
return accessToken;
|
return new { token= accessToken };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -164,5 +164,6 @@ export default function useAuths(opt) {
|
|||||||
logoutFun,
|
logoutFun,
|
||||||
clearStorage,
|
clearStorage,
|
||||||
registerFun,
|
registerFun,
|
||||||
|
loginSuccess,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ const type = ref(route.query.state);
|
|||||||
const message = ref("");
|
const message = ref("");
|
||||||
const scheme = ref("");
|
const scheme = ref("");
|
||||||
const authData = ref("");
|
const authData = ref("");
|
||||||
|
const closeWindow = () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.close();
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
watch(
|
watch(
|
||||||
() => code.value,
|
() => code.value,
|
||||||
async (val) => {
|
async (val) => {
|
||||||
@@ -31,19 +36,25 @@ watch(
|
|||||||
scheme.value = "QQ";
|
scheme.value = "QQ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (type.value === "0") {
|
try {
|
||||||
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
if (type.value === "0") {
|
||||||
authData.value = data;
|
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
||||||
} else if (type.value === "1") {
|
authData.value = data;
|
||||||
const { data } = await authOtherBind({ code: val }, scheme.value);
|
} else if (type.value === "1") {
|
||||||
authData.value = data;
|
const { data } = await authOtherBind({ code: val }, scheme.value);
|
||||||
|
authData.value = data;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error.status === 403) {
|
||||||
|
closeWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.opener.postMessage({
|
window.opener.postMessage({
|
||||||
authData: JSON.stringify(authData.value),
|
authData: JSON.stringify(authData.value),
|
||||||
type: scheme.value,
|
type: scheme.value,
|
||||||
});
|
});
|
||||||
console.log(authData.value, "我是打开的窗口页");
|
|
||||||
message.value = "授权成功";
|
message.value = "授权成功";
|
||||||
|
closeWindow();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ import useUserStore from "@/stores/user";
|
|||||||
import useConfigStore from "@/stores/config";
|
import useConfigStore from "@/stores/config";
|
||||||
|
|
||||||
const configStore = useConfigStore();
|
const configStore = useConfigStore();
|
||||||
const { loginFun, registerFun } = useAuths();
|
const { loginFun, registerFun, loginSuccess } = useAuths();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const loginFormRef = ref();
|
const loginFormRef = ref();
|
||||||
@@ -318,6 +318,15 @@ const handleGiteeLogin = () => {
|
|||||||
"width=500,height=500,left=50,top=50"
|
"width=500,height=500,left=50,top=50"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.addEventListener("message", async (e) => {
|
||||||
|
const { authData, type } = e.data;
|
||||||
|
console.log(authData, "传到登录页的值");
|
||||||
|
if (authData) {
|
||||||
|
await loginSuccess({ data: JSON.parse(authData) });
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.login {
|
.login {
|
||||||
|
|||||||
@@ -131,10 +131,7 @@ const handleGiteeLogin = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("message", async (e) => {
|
window.addEventListener("message", async (e) => {
|
||||||
console.log(e, "我是账号设置页");
|
|
||||||
const { authData, type } = e.data;
|
|
||||||
if (e.data) {
|
if (e.data) {
|
||||||
console.log(authData, type, "2333");
|
|
||||||
await checkList();
|
await checkList();
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user