接入第三方登录(已接入Gitee[理论justAuth支持都可以接入]--抢先预览版

This commit is contained in:
weir
2021-08-13 23:44:52 +08:00
parent c588a4d975
commit 133cb49c42
27 changed files with 1049 additions and 44 deletions

View File

@ -45,6 +45,11 @@
<span v-else> 中...</span>
</el-button>
</el-form-item>
<el-form-item style="width:100%;">
<el-button @click="doAuth2Login" title="使用 Gitee 帐号登录">
<span class="gitee-login-title">使用 Gitee 帐号登录</span>
</el-button>
</el-form-item>
</el-form>
<!-- 底部 -->
<div class="el-login-footer">
@ -54,7 +59,7 @@
</template>
<script>
import { getCodeImg } from "@/api/login";
import { getCodeImg,giteeLogin } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
@ -135,6 +140,14 @@ export default {
});
}
});
},
doAuth2Login() {
console.log("开始Oauth登录...");
this.loading = true;
giteeLogin().then((res) => {
console.log(res.url);
window.location.href = res.url;
});
}
}
};

View File

@ -0,0 +1,27 @@
<template>
<div>登录成功</div>
</template>
<script>
import { getToken, setToken, removeToken } from '@/utils/auth'
export default {
created() {
var token = this.getOauthToken();
setToken(token);
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
},
methods: {
getOauthToken() {
console.log(this);
var h = window.location.href;
var token = "token=";
return h.substring(h.indexOf(token)+token.length);
}
},
}
</script>
<style>
</style>