提交 878780f2 编写于 作者: F freesky-edward

Add gitee login request when signing CLA

上级 94bb5f53
......@@ -177,6 +177,12 @@ Please select one applicable statement from the following and fill in the blanks
<input type="text" id="legalentity-date" class = "require" maxlength="100" />
</td>
</tr>
<tr>
<td>
<input type="hidden" value="" id="oauth-code" />
<input type="hidden" value="en" id="language" />
</td>
</tr>
<tr>
<td colspan="2">
* require field. Please make sure the E-Mail is related with your gitee account.
......
......@@ -186,6 +186,12 @@ title = "签署CLA"
<input type="text" id="legalentity-date" class = "require" maxlength="100" />
</td>
</tr>
<tr>
<td>
<input type="hidden" value="" id="oauth-code" />
<input type="hidden" value="zh" id="language" />
</td>
</tr>
<tr>
<td colspan="2">
* 必填。请确保邮箱与你的gitee账号绑定。
......
......@@ -18,6 +18,8 @@
<!-- used to for mobile -->
<script src="{{ .Site.BaseURL }}js/flexible.js"></script>
<script src="{{ .Site.BaseURL }}js/common.js"></script>
<script src="{{ .Site.BaseURL }}js/dist/jso.js"></script>
<script src="{{ .Site.BaseURL }}js/cla.js?t=20191230"></script>
<div id="mask" onclick="hideNav()"></div>
......
$(function () {
getCode();
initClaPage();
initCurrentDate();
})
......@@ -25,6 +26,74 @@ function initCurrentDate() {
}
}
function getCode() {
code = getQueryString("code")
if (!code || code == "") {
oauthLogin();
}
else {
$('#oauth-code').val(code);
}
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
function getLanguage() {
var url = window.location.href;
if (url.indexOf("/en/") >= 0 ) {
return "en";
}
if (url.indexOf("/zh/") >= 0 ) {
return "zh";
}
return "en"
}
function oauthLogin() {
code = $('#oauth-code').val();
if (!code || code == "") {
let config = {
providerID: "openeuler_bot",
client_id: "88913556129bdae86458ec266f174b0cc5833198641e0e219891e7eb463bd3bf",
redirect_uri: "https://openeuler.org/en/cla.html",
response_type: "code",
authorization: "https://gitee.com/oauth/authorize",
scopes: { request: ["user_info", "emails"]}
}
if (getLanguage() == "zh") {
config = {
providerID: "openeuler_bot",
client_id: "6c298174d665b993c8a4dd56b0976654d3ef6f59af6c88f59b5b0c99f635c893",
redirect_uri: "https://openeuler.org/zh/cla.html",
response_type: "code",
authorization: "https://gitee.com/oauth/authorize",
scopes: { request: ["user_info", "emails"]}
}
}
let client = new jso.JSO(config)
client.callback()
let f = new jso.Fetcher(client)
let url = 'https://gitee.com/v5/users/freesky-edward'
f.fetch(url, {})
.then((data) => {
return data.json()
})
.then((data) => {
console.log("I got protected json data from the API", data)
})
.catch((err) => {
console.error("Error from fetcher", err)
})
}
}
// init cla page
function initClaPage() {
if ($('#cla-type-table').length) {
......@@ -167,6 +236,8 @@ function initClaPage() {
"email": $.trim($('#legalentity-email').val()),
"telephone": $.trim($('#legalentity-telephone').val()),
"fax": $.trim($('#legalentity-fax').val()),
"code": $.trim($('#oauth-code').val()),
"lang": $.trim($('#language').val()),
};
}
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册