From 878780f200be2d852fa40ad77213504a4018393c Mon Sep 17 00:00:00 2001 From: freesky-edward Date: Sat, 4 Jan 2020 20:39:59 +0800 Subject: [PATCH] Add gitee login request when signing CLA --- content/en/cla.md | 6 ++ content/zh/cla.md | 8 ++- themes/project/layouts/partials/scripts.html | 4 +- themes/project/static/js/cla.js | 71 ++++++++++++++++++++ themes/project/static/js/dist/jso.js | 2 + themes/project/static/js/dist/jso.js.map | 1 + 6 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 themes/project/static/js/dist/jso.js create mode 100644 themes/project/static/js/dist/jso.js.map diff --git a/content/en/cla.md b/content/en/cla.md index 7a913d8..25b69d8 100644 --- a/content/en/cla.md +++ b/content/en/cla.md @@ -177,6 +177,12 @@ Please select one applicable statement from the following and fill in the blanks + + + + + + * require field. Please make sure the E-Mail is related with your gitee account. diff --git a/content/zh/cla.md b/content/zh/cla.md index 3564b22..86c4221 100644 --- a/content/zh/cla.md +++ b/content/zh/cla.md @@ -186,6 +186,12 @@ title = "签署CLA" + + + + + + * 必填。请确保邮箱与你的gitee账号绑定。 @@ -208,4 +214,4 @@ title = "签署CLA" - \ No newline at end of file + diff --git a/themes/project/layouts/partials/scripts.html b/themes/project/layouts/partials/scripts.html index b344409..caac3f9 100644 --- a/themes/project/layouts/partials/scripts.html +++ b/themes/project/layouts/partials/scripts.html @@ -18,6 +18,8 @@ + +
@@ -109,4 +111,4 @@ } }) }); - \ No newline at end of file + diff --git a/themes/project/static/js/cla.js b/themes/project/static/js/cla.js index 01f4368..278c66a 100644 --- a/themes/project/static/js/cla.js +++ b/themes/project/static/js/cla.js @@ -1,4 +1,5 @@ $(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()), }; } diff --git a/themes/project/static/js/dist/jso.js b/themes/project/static/js/dist/jso.js new file mode 100644 index 0000000..7baab64 --- /dev/null +++ b/themes/project/static/js/dist/jso.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.jso=t():e.jso=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}([function(e,t,n){var r=n(40)("wks"),o=n(25),i=n(1).Symbol,u="function"==typeof i;(e.exports=function(e){return r[e]||(r[e]=u&&i[e]||(u?i:o)("Symbol."+e))}).store=r},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t){var n=e.exports={version:"2.5.3"};"number"==typeof __e&&(__e=n)},function(e,t,n){var r=n(10);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){var r=n(16),o=n(44);e.exports=n(9)?function(e,t,n){return r.f(e,t,o(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){var r=n(1),o=n(2),i=n(4),u=n(8),a=n(15),c=function(e,t,n){var s,f,l,p,h=e&c.F,d=e&c.G,v=e&c.S,y=e&c.P,g=e&c.B,b=d?r:v?r[t]||(r[t]={}):(r[t]||{}).prototype,w=d?o:o[t]||(o[t]={}),_=w.prototype||(w.prototype={});for(s in d&&(n=t),n)l=((f=!h&&b&&void 0!==b[s])?b:n)[s],p=g&&f?a(l,r):y&&"function"==typeof l?a(Function.call,l):l,b&&u(b,s,l,e&c.U),w[s]!=l&&i(w,s,p),y&&_[s]!=l&&(_[s]=l)};r.core=o,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports={}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){var r=n(1),o=n(4),i=n(7),u=n(25)("src"),a=Function.toString,c=(""+a).split("toString");n(2).inspectSource=function(e){return a.call(e)},(e.exports=function(e,t,n,a){var s="function"==typeof n;s&&(i(n,"name")||o(n,"name",t)),e[t]!==n&&(s&&(i(n,u)||o(n,u,e[t]?""+e[t]:c.join(String(t)))),e===r?e[t]=n:a?e[t]?e[t]=n:o(e,t,n):(delete e[t],o(e,t,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||a.call(this)})},function(e,t,n){e.exports=!n(27)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0?r:n)(e)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(43),o=n(22);e.exports=function(e){return r(o(e))}},function(e,t,n){var r=n(84),o=n(39);e.exports=Object.keys||function(e){return r(e,o)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t,n){var r=n(10),o=n(1).document,i=r(o)&&r(o.createElement);e.exports=function(e){return i?o.createElement(e):{}}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;nn;)t.push(arguments[n++]);return g[++y]=function(){a("function"==typeof e?e:Function(e),t)},r(y),y},h=function(e){delete g[e]},"process"==n(13)(l)?r=function(e){l.nextTick(u(b,e,1))}:v&&v.now?r=function(e){v.now(u(b,e,1))}:d?(i=(o=new d).port2,o.port1.onmessage=w,r=u(i.postMessage,i,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(r=function(e){f.postMessage(e+"","*")},f.addEventListener("message",w,!1)):r="onreadystatechange"in s("script")?function(e){c.appendChild(s("script")).onreadystatechange=function(){c.removeChild(this),b.call(e)}}:function(e){setTimeout(u(b,e,1),0)}),e.exports={set:p,clear:h}},function(e,t,n){var r=n(3),o=n(14),i=n(0)("species");e.exports=function(e,t){var n,u=r(e).constructor;return void 0===u||void 0==(n=r(u)[i])?t:o(n)}},function(e,t,n){var r=n(1).document;e.exports=r&&r.documentElement},function(e,t){e.exports=!1},function(e,t,n){"use strict";var r=n(35),o=n(5),i=n(8),u=n(4),a=n(7),c=n(6),s=n(74),f=n(18),l=n(71),p=n(0)("iterator"),h=!([].keys&&"next"in[].keys()),d=function(){return this};e.exports=function(e,t,n,v,y,g,b){s(n,t,v);var w,_,m,k=function(e){if(!h&&e in P)return P[e];switch(e){case"keys":case"values":return function(){return new n(this,e)}}return function(){return new n(this,e)}},O=t+" Iterator",x="values"==y,j=!1,P=e.prototype,S=P[p]||P["@@iterator"]||y&&P[y],T=!h&&S||k(y),E=y?x?k("entries"):T:void 0,C="Array"==t&&P.entries||S;if(C&&(m=l(C.call(new e)))!==Object.prototype&&m.next&&(f(m,O,!0),r||a(m,p)||u(m,p,d)),x&&S&&"values"!==S.name&&(j=!0,T=function(){return S.call(this)}),r&&!b||!h&&!j&&P[p]||u(P,p,T),c[t]=T,c[O]=d,y)if(w={values:x?T:k("values"),keys:g?T:k("keys"),entries:E},b)for(_ in w)_ in P||i(P,_,w[_]);else o(o.P+o.F*(h||j),t,w);return w}},function(e,t,n){var r=n(0)("unscopables"),o=Array.prototype;void 0==o[r]&&n(4)(o,r,{}),e.exports=function(e){o[r][e]=!0}},function(e,t,n){var r=n(22);e.exports=function(e){return Object(r(e))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,n){var r=n(1),o=r["__core-js_shared__"]||(r["__core-js_shared__"]={});e.exports=function(e){return o[e]||(o[e]={})}},function(e,t,n){var r=n(21),o=Math.min;e.exports=function(e){return e>0?o(r(e),9007199254740991):0}},function(e,t,n){var r=n(23),o=n(41),i=n(83);e.exports=function(e){return function(t,n,u){var a,c=r(t),s=o(c.length),f=i(u,s);if(e&&n!=n){for(;s>f;)if((a=c[f++])!=a)return!0}else for(;s>f;f++)if((e||f in c)&&c[f]===n)return e||f||0;return!e&&-1}}},function(e,t,n){var r=n(13);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e){e.exports={name:"jso",version:"4.1.1",description:"OAuth 2.0 implementation in Javascript",main:"dist/jso.js",module:"src/JSO.js",scripts:{test:"true",preversion:"npm test",version:"npm run build && git add -A dist",postversion:"git push && git push --tags && npm publish",build:"webpack --mode production --config webpack.config.js"},babel:{presets:["env"]},repository:{type:"git",url:"https://github.com/andreassolberg/jso.git"},keywords:["oauth","authentication","authorization","rest","api","ajax","jquery"],files:["src"],eslintConfig:{env:{es6:!0,browser:!0,node:!1}},devDependencies:{"babel-core":"^6.26.0","babel-loader":"^7.1.4","babel-preset-env":"^1.6.1","babel-preset-react":"^6.24.1",qunit:"^2.5.1",webpack:"^4.1.1","webpack-cli":"^2.0.12"},author:"Andreas Åkre Solberg",license:"LGPL-2.1",bugs:{url:"https://github.com/andreassolberg/jso/issues"},homepage:"https://github.com/andreassolberg/jso",dependencies:{}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n2)throw new Error("Reccursion error. Expired tokens deleted and tried again multiple times.");var o={},i={mode:"cors"};return t&&(i=t,Object.assign(i,t)),t&&t.jso&&Object.assign(o,t.jso),this.jso.getToken(o).catch(function(e){console.error("Error fetching token to use ",e)}).then(function(o){return i.headers||(i.headers={}),i.headers.Authorization="Bearer "+o.access_token,r._fetch(e,i).catch(function(o){if(o instanceof u.default)return console.error("Token was expired. Deleting all tokens for this provider and get a new one",o),r.jso.wipeTokens(),r.fetch(e,t,n+1)})})}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=function(){function e(e,t){for(var n=0;n2)throw new Error("Reccursion error. Expired tokens deleted and tried again multiple times.");var o={},i={mode:"cors"};return t&&(i=t,Object.assign(i,t)),t&&t.jso&&Object.assign(o,t.jso),this.jso.getToken(o).catch(function(e){console.error("Error fetching token to use ",e)}).then(function(o){return i.headers||(i.headers={}),i.headers.Authorization="Bearer "+o.access_token,r._fetch(e,i).catch(function(o){if(o instanceof u.default)return console.error("Token was expired. Deleting all tokens for this provider and get a new one",o),r.jso.wipeTokens(),r.fetch(e,t,n+1)})})}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=function(){function e(e,t){for(var n=0;nw;w++)if((y=t?b(u(d=e[w])[0],d[1]):b(e[w]))===s||y===f)return y}else for(v=g.call(e);!(d=v.next()).done;)if((y=o(v,b,d.value,t))===s||y===f)return y}).BREAK=s,t.RETURN=f},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){"use strict";var r,o,i,u,a=n(35),c=n(1),s=n(15),f=n(19),l=n(5),p=n(10),h=n(14),d=n(66),v=n(65),y=n(33),g=n(32).set,b=n(60)(),w=n(17),_=n(31),m=n(30),k=c.TypeError,O=c.process,x=c.Promise,j="process"==f(O),P=function(){},S=o=w.f,T=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(0)("species")]=function(e){e(P,P)};return(j||"function"==typeof PromiseRejectionEvent)&&e.then(P)instanceof t}catch(e){}}(),E=function(e){var t;return!(!p(e)||"function"!=typeof(t=e.then))&&t},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;b(function(){for(var r=e._v,o=1==e._s,i=0,u=function(t){var n,i,u=o?t.ok:t.fail,a=t.resolve,c=t.reject,s=t.domain;try{u?(o||(2==e._h&&M(e),e._h=1),!0===u?n=r:(s&&s.enter(),n=u(r),s&&s.exit()),n===t.promise?c(k("Promise-chain cycle")):(i=E(n))?i.call(n,a,c):a(n)):c(r)}catch(e){c(e)}};n.length>i;)u(n[i++]);e._c=[],e._n=!1,t&&!e._h&&R(e)})}},R=function(e){g.call(c,function(){var t,n,r,o=e._v,i=L(e);if(i&&(t=_(function(){j?O.emit("unhandledRejection",o,e):(n=c.onunhandledrejection)?n({promise:e,reason:o}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",o)}),e._h=j||L(e)?2:1),e._a=void 0,i&&t.e)throw t.v})},L=function(e){return 1!==e._h&&0===(e._a||e._c).length},M=function(e){g.call(c,function(){var t;j?O.emit("rejectionHandled",e):(t=c.onrejectionhandled)&&t({promise:e,reason:e._v})})},I=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),C(t,!0))},A=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw k("Promise can't be resolved itself");(t=E(e))?b(function(){var r={_w:n,_d:!1};try{t.call(e,s(A,r,1),s(I,r,1))}catch(e){I.call(r,e)}}):(n._v=e,n._s=1,C(n,!1))}catch(e){I.call({_w:n,_d:!1},e)}}};T||(x=function(e){d(this,x,"Promise","_h"),h(e),r.call(this);try{e(s(A,this,1),s(I,this,1))}catch(e){I.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=n(59)(x.prototype,{then:function(e,t){var n=S(y(this,x));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=j?O.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),i=function(){var e=new r;this.promise=e,this.resolve=s(A,e,1),this.reject=s(I,e,1)},w.f=S=function(e){return e===x||e===u?new i(e):o(e)}),l(l.G+l.W+l.F*!T,{Promise:x}),n(18)(x,"Promise"),n(58)("Promise"),u=n(2).Promise,l(l.S+l.F*!T,"Promise",{reject:function(e){var t=S(this);return(0,t.reject)(e),t.promise}}),l(l.S+l.F*(a||!T),"Promise",{resolve:function(e){return m(a&&this===u?x:this,e)}}),l(l.S+l.F*!(T&&n(57)(function(e){x.all(e).catch(P)})),"Promise",{all:function(e){var t=this,n=S(t),r=n.resolve,o=n.reject,i=_(function(){var n=[],i=0,u=1;v(e,!1,function(e){var a=i++,c=!1;n.push(void 0),u++,t.resolve(e).then(function(e){c||(c=!0,n[a]=e,--u||r(n))},o)}),--u||r(n)});return i.e&&o(i.v),n.promise},race:function(e){var t=this,n=S(t),r=n.reject,o=_(function(){v(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return o.e&&r(o.v),n.promise}})},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){"use strict";var r=n(37),o=n(68),i=n(6),u=n(23);e.exports=n(36)(Array,"Array",function(e,t){this._t=u(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,o(1)):o(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])},"values"),i.Arguments=i.Array,r("keys"),r("values"),r("entries")},function(e,t,n){for(var r=n(69),o=n(24),i=n(8),u=n(1),a=n(4),c=n(6),s=n(0),f=s("iterator"),l=s("toStringTag"),p=c.Array,h={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},d=o(h),v=0;vc;)r.f(e,n=u[c++],t[n]);return e}},function(e,t,n){var r=n(3),o=n(72),i=n(39),u=n(20)("IE_PROTO"),a=function(){},c=function(){var e,t=n(26)("iframe"),r=i.length;for(t.style.display="none",n(34).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("