Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-18165 cla: add GitHub login #4244

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tools/cldr-apps/js/src/esm/cldrAuth.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as cldrClient from "../esm/cldrClient.mjs";
import * as cldrStatus from "../esm/cldrStatus.mjs";

/**
* Get the oauth login URL. See GithubLoginFactory#getLoginUrl()
* @param {object} o options bag
* @param {string} o.service which service, currently only 'github' is accepted
* @param {string} o.intent what the login URL is used for, currently only 'cla'
* @param {boolean} o.relogin if true, attempt re-login
*/
export async function getLoginUrl(o) {
const { service, intent, relogin } = o;
if (service !== "github")
throw Error(`only support service='github' but got ${service}`);
if (intent !== "cla")
throw Error(`only support intent='cla' but got ${intent}`);
const client = await cldrClient.getClient();
const { url } = (await client.apis.auth.oauthUrl()).body;
const u = new URL(url);
const redir = new URL(window.location);
redir.search = "";
redir.hash = "";
redir.pathname = cldrStatus.getContextPath() + "/github-login";
u.searchParams.set("redirect_uri", redir);
if (relogin) {
u.searchParams.set("prompt", "select_account");
}
return u;
}

/**
* If a valid github ID is in the session, return it, otherwise falsy
* @returns github ID or falsy
*/
export async function getGithubIdFromSession() {
try {
const client = await cldrClient.getClient();
const { id } = (await client.apis.auth.oauthSession()).body;
return id;
} catch (e) {
console.error(e);
console.error("getGithubIdFromSession() failed");
}
return null;
}
1 change: 1 addition & 0 deletions tools/cldr-apps/js/src/esm/cldrCla.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as cldrNotify from "../esm/cldrNotify.mjs";
* see ClaSignature.java
* @typedef {Object} ClaSignature
* @property {boolean} corporate true if a corporate signature
* @property {boolean} noRights true if employer asserts no rights
* @property {string} email
* @property {string} employer
* @property {string} name
Expand Down
4 changes: 4 additions & 0 deletions tools/cldr-apps/js/src/esm/cldrComponents.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
Button,
Card,
Checkbox,
Col,
Collapse,
CollapsePanel,
Form,
Expand All @@ -33,6 +34,7 @@ import {
Popover,
Progress,
Radio,
Row,
Select,
Spin,
Steps,
Expand Down Expand Up @@ -62,6 +64,7 @@ function setup(app) {
app.component("a-button", Button);
app.component("a-card", Card);
app.component("a-checkbox", Checkbox);
app.component("a-col", Col);
app.component("a-collapse-panel", CollapsePanel);
app.component("a-collapse", Collapse);
app.component("a-form-item", Form.Item);
Expand All @@ -77,6 +80,7 @@ function setup(app) {
app.component("a-progress", Progress);
app.component("a-radio-group", Radio.Group);
app.component("a-radio", Radio);
app.component("a-row", Row);
app.component("a-select", Select);
app.component("a-spin", Spin);
app.component("a-step", Steps.Step);
Expand Down
2 changes: 0 additions & 2 deletions tools/cldr-apps/js/src/md/cla.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Contributor License Agreement (CLA)

Hello. We need your permission to use the data and information that you submit to the Unicode CLDR Survey Tool. To do this, we need a contributor license agreement (CLA) on file for you or your employer so that Unicode has the required permissions to use your contributions in our products and services. If you are seeing this message, it means we do not have such a CLA on file. If you believe you are already under a Unicode CLA (either your own or your employer’s) and are seeing this message in error, or if you have further questions, please contact [`[email protected]`](mailto:[email protected]).

If you would like to sign Unicode’s standard CLA so that you may contribute to other Unicode projects as well as Survey Tool, please refer to our [IP Policies](https://www.unicode.org/policies/licensing_policy.html) to find out how to get a standard CLA in place.

*Alternatively*, if you do not wish to sign Unicode’s standard CLA and you wish to contribute only to the CLDR Survey Tool, you may agree to the following terms for your Survey Tool contributions:
Expand Down
6 changes: 4 additions & 2 deletions tools/cldr-apps/js/src/views/MainMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<li>
<ul>
<li><a href="#account///">Account Settings</a></li>
<li v-if="showClaMenu"><a href="#cla///">Sign CLA</a></li>
<li v-if="showClaMenu">
<a href="#cla///">CLA (Contributor License Agreement) Status</a>
</li>
</ul>
</li>
<li v-if="!isAdmin && !accountLocked">
Expand Down Expand Up @@ -155,7 +157,7 @@ export default {
recentActivityUrl: null,
uploadXmlUrl: null,
userId: 0,
showClaMenu: false, // off by default, see CLDR-16499
showClaMenu: true,
};
},

Expand Down
Loading
Loading