提交 24f9be18 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!44 Add gitee authentication support when signing CLA

Merge pull request !44 from freesky-edward/oauth
......@@ -177,6 +177,13 @@ 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="" id="client" />
<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.
......
......@@ -6,7 +6,7 @@ title = "Contributions to the Community"
Before you start, please note that you must have a Gitee account. To register an account, go to [https://gitee.com/signup](https://gitee.com/signup).
We appreciate your contributions to the community. By signing a contributor license agreement (CLA), we ensure that the community is free to use your contributions. The signing link is [https://openeuler.org/en/cla.html](https://openeuler.org/en/cla.html).
We appreciate your contributions to the community. By signing a contributor license agreement (CLA), we ensure that the community is free to use your contributions. The signing link is [https://openeuler.org/en/cla.html](https://openeuler.org/en/cla.html). Gitee authentication is required when signing CLA.
Select a project you may be interested in from the project catalog at [https://gitee.com/openeuler](https://gitee.com/openeuler)-Code Sources, [https://gitee.com/src-openeuler](https://gitee.com/src-openeuler)-Package Sources. Read the ```CONTRIBUTING.md``` file for project information and contribution instructions. If you are not sure which project is suitable for you, refer to the introduction of the [SIGs](./sig.html) in the community.
......
......@@ -186,6 +186,13 @@ 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="" id="client" />
<input type="hidden" value="zh" id="language" />
</td>
</tr>
<tr>
<td colspan="2">
* 必填。请确保邮箱与你的gitee账号绑定。
......@@ -208,4 +215,4 @@ title = "签署CLA"
<label id="tip-cla-label"></label>
</td>
</tr>
</table>
\ No newline at end of file
</table>
......@@ -8,7 +8,7 @@ title = "社区贡献"
签署社区CLA。签署地址:[https://openeuler.org/zh/cla.html](https://openeuler.org/zh/cla.html),根据情况选择**个人独立贡献者**或者**法律实体贡献者**签署。
选择贡献项目,所有项目参见:代码仓组织-[https://gitee.com/openeuler](https://gitee.com/openeuler), 软件包组织-[https://gitee.com/src-openeuler](https://gitee.com/src-openeuler)。 阅读项目下 ```CONTRIBUTING.md``` 文件了解该项目贡献指导。 如果您不确定哪个项目适合您,建议参考社区 [SIG](./sig.html)组介绍。
选择贡献项目,所有项目参见:代码仓组织-[https://gitee.com/openeuler](https://gitee.com/openeuler), 软件包组织-[https://gitee.com/src-openeuler](https://gitee.com/src-openeuler)。 阅读项目下 ```CONTRIBUTING.md``` 文件了解该项目贡献指导。 如果您不确定哪个项目适合您,建议参考社区 [SIG](./sig.html)组介绍。签署CLA必须要登录Gitee。
了解项目的编码规范。了解项目编码规范就有助于您的提交快速接纳,在每个项目里有关于该项目的编码规范介绍,文件名为```code-of-conduct.md```,位于项目根目录下,如果项目下未提供,请参考社区编码规范,地址:[https://gitee.com/openeuler/community/blob/master/code-of-conduct.md](https://gitee.com/openeuler/community/blob/master/code-of-conduct.md)<br>
......
......@@ -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>
......@@ -109,4 +111,4 @@
}
})
});
</script>
\ No newline at end of file
</script>
......@@ -25,8 +25,72 @@ function initCurrentDate() {
}
}
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 readCookie(name) {
var namePrefix = name + "=";
var cookies = document.cookie.split(';');
for(var i=0; i < cookies.length; i++) {
var c = cookies[i];
while (c.charAt(0)==' ') c = c.substring(1, c.length);
if (c.indexOf(namePrefix) == 0) return c.substring(namePrefix.length, c.length);
}
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() {
let config = {
providerID: "openeuler_bot",
client_id: $("#client").val(),
redirect_uri: window.location.origin + "/cla",
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/user'
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() {
$("#client").val("d00e9b289d8cf8f98e2fc68a9c240304f6413007d82d30701cd1da7e937db75c");
cla = readCookie("cla-info")
if (!cla || cla == "") {
oauthLogin();
}
if ($('#cla-type-table').length) {
// default show individual
$('#individual-table').show();
......@@ -48,6 +112,42 @@ function initClaPage() {
});
}
type = readCookie("type")
if (type && type == "0") {
$('#individual-email').val(readCookie("email"));
$('#individual-address').val(readCookie("address"));
$('#individual-name').val(readCookie("name"));
$('#individual-telephone').val(readCookie("telephone"));
$('#individual-fax').val(readCookie("fax"));
$('#individual-date').val(readCookie("date"));
$('#individual-table').show();
$('#legalentity-table').hide();
$("#sign-cla-button").attr('disabled',true)
$("#reset-cla-button").attr('disabled',true)
} else if (type && type == "1") {
$('#legalentity-name').val(readCookie("name"));
$('#legalentity-title').val(readCookie("title"));
$('#legalentity-corporation').val(readCookie("corporation"));
$('#legalentity-address').val(readCookie("address"));
$('#legalentity-date').val(readCookie("date"));
$('#legalentity-email').val(readCookie("email"));
$('#legalentity-telephone').val(readCookie("telephone"));
$('#legalentity-fax').val(readCookie("fax"));
$('#individual-table').hide();
$('#legalentity-table').show();
$("#sign-cla-button").attr('disabled',true)
$("#reset-cla-button").attr('disabled',true)
}
$('#individual-email').val(readCookie("email"));
$("#individual-email").attr('disabled',true)
if ($('#sign-cla-button').length) {
$("#sign-cla-button").bind('click', function () {
v = parseInt($('input[name="cla-type-radio"]:checked').val());
......@@ -152,6 +252,9 @@ function initClaPage() {
"email": $.trim($('#individual-email').val()),
"telephone": $.trim($('#individual-telephone').val()),
"fax": $.trim($('#individual-fax').val()),
"code": $.trim($('#oauth-code').val()),
"lang": $.trim($('#language').val()),
"client": $.trim($('#client').val()),
};
} else {
// legalentity
......@@ -167,6 +270,9 @@ 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()),
"client": $.trim($('#client').val()),
};
}
......@@ -206,6 +312,12 @@ function initClaPage() {
} else {
alert("Telephone is already registered!");
}
} else if (data.errorCode == 4) {
if (lang == "zh-cn") {
alert("注册邮箱与gitee账号邮箱不一致,请在这里检查:https://gitee.com/profile/emails")
} else {
alert("The submit email is not the gitee account email. Please checck in https://gitee.com/profile/emails.");
}
}
}
}
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册