summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-08-06 02:11:08 +0100
committerGitHub <noreply@github.com>2021-08-05 21:11:08 -0400
commitab9bb54144f136bbbba2ce2e94fd88c0be0ee1cf (patch)
treef8b283e33e70cbc3d827879c4774de2b41450ab0 /web_src
parent7e7006e00d8d0d5ce4c871685d421269049e4b39 (diff)
downloadgitea-ab9bb54144f136bbbba2ce2e94fd88c0be0ee1cf.tar.gz
gitea-ab9bb54144f136bbbba2ce2e94fd88c0be0ee1cf.zip
Add microsoft oauth2 providers (#16544)
* Clean up oauth2 providers Signed-off-by: Andrew Thornton <art27@cantab.net> * Add AzureAD, AzureADv2, MicrosoftOnline OAuth2 providers Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review * remove unused Scopes Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/index.js47
1 files changed, 15 insertions, 32 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 4900d37f3f..17bf31d6a6 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -2027,19 +2027,17 @@ function initAdmin() {
const provider = $('#oauth2_provider').val();
switch (provider) {
- case 'gitea':
- case 'nextcloud':
- case 'mastodon':
- $('#oauth2_use_custom_url').attr('checked', 'checked');
- // fallthrough intentional
- case 'github':
- case 'gitlab':
- $('.oauth2_use_custom_url').show();
- break;
case 'openidConnect':
$('.open_id_connect_auto_discovery_url input').attr('required', 'required');
$('.open_id_connect_auto_discovery_url').show();
break;
+ default:
+ if ($(`#${provider}_customURLSettings`).data('required')) {
+ $('#oauth2_use_custom_url').attr('checked', 'checked');
+ }
+ if ($(`#${provider}_customURLSettings`).data('available')) {
+ $('.oauth2_use_custom_url').show();
+ }
}
onOAuth2UseCustomURLChange(applyDefaultValues);
}
@@ -2050,29 +2048,14 @@ function initAdmin() {
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');
if ($('#oauth2_use_custom_url').is(':checked')) {
- if (applyDefaultValues) {
- $('#oauth2_token_url').val($(`#${provider}_token_url`).val());
- $('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());
- $('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());
- $('#oauth2_email_url').val($(`#${provider}_email_url`).val());
- }
-
- switch (provider) {
- case 'github':
- $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input, .oauth2_email_url input').attr('required', 'required');
- $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url, .oauth2_email_url').show();
- break;
- case 'nextcloud':
- case 'gitea':
- case 'gitlab':
- $('.oauth2_token_url input, .oauth2_auth_url input, .oauth2_profile_url input').attr('required', 'required');
- $('.oauth2_token_url, .oauth2_auth_url, .oauth2_profile_url').show();
- $('#oauth2_email_url').val('');
- break;
- case 'mastodon':
- $('.oauth2_auth_url input').attr('required', 'required');
- $('.oauth2_auth_url').show();
- break;
+ for (const custom of ['token_url', 'auth_url', 'profile_url', 'email_url', 'tenant']) {
+ if (applyDefaultValues) {
+ $(`#oauth2_${custom}`).val($(`#${provider}_${custom}`).val());
+ }
+ if ($(`#${provider}_${custom}`).data('available')) {
+ $(`.oauth2_${custom} input`).attr('required', 'required');
+ $(`.oauth2_${custom}`).show();
+ }
}
}
}