-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLDR-18165 cla: add GitHub login (#4244)
- Loading branch information
Showing
24 changed files
with
1,367 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.