twitter.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <form action="/_api/admin/security/passport-twitter" method="post" class="form-horizontal passportStrategy" id="twitterSetting" role="form"
  2. {% if isRestartingServerNeeded %}style="opacity: 0.4;"{% endif %}>
  3. <legend>{{ t("security_setting.OAuth.Twitter.name") }}{{ t("security_setting.configuration") }}</legend>
  4. <p class="well alert-anchor">{{ t("security_setting.OAuth.connect_api_manager", "https://github.com/settings/developers", "GitHub Developer Settings") }}</p>
  5. {% set nameForIsTwitterEnabled = "settingForm[security:passport-twitter:isEnabled]" %}
  6. {% set isTwitterEnabled = settingForm['security:passport-twitter:isEnabled'] %}
  7. <div class="form-group">
  8. <label for="{{nameForIsTwitterEnabled}}" class="col-xs-3 control-label">{{ t("security_setting.OAuth.Twitter.name") }}</label>
  9. <div class="col-xs-6">
  10. <div class="btn-group btn-toggle" data-toggle="buttons">
  11. <label class="btn btn-default btn-rounded btn-outline {% if isTwitterEnabled %}active{% endif %}" data-active-class="primary">
  12. <input name="{{nameForIsTwitterEnabled}}" value="true" type="radio"
  13. {% if true === isTwitterEnabled %}checked{% endif %}> ON
  14. </label>
  15. <label class="btn btn-default btn-rounded btn-outline {% if !isTwitterEnabled %}active{% endif %}" data-active-class="default">
  16. <input name="{{nameForIsTwitterEnabled}}" value="false" type="radio"
  17. {% if !isTwitterEnabled %}checked{% endif %}> OFF
  18. </label>
  19. </div>
  20. </div>
  21. </div>
  22. <fieldset id="passport-twitter-hide-when-disabled" {%if !isTwitterEnabled %}style="display: none;"{% endif %}>
  23. {# Help Section #}
  24. <hr>
  25. <ol id="collapseHelpForTwitterOauth" class="collapse">
  26. <li>{{ t("security_setting.OAuth.Twitter.register_1", "https://console.cloud.google.com/apis/credentials", "Google Cloud Platform API Manager") }}</li>
  27. <li>{{ t("security_setting.OAuth.Twitter.register_2") }}</li>
  28. <li>{{ t("security_setting.OAuth.Twitter.register_3") }}</li>
  29. <li>{{ t("security_setting.OAuth.Twitter.register_4", "https://${growi.host}/passport/google/callback", "${growi.host}") }}</li>
  30. <li>{{ t("security_setting.OAuth.Twitter.register_5") }}</li>
  31. </ol>
  32. <div class="form-group">
  33. <label for="settingForm[security:passport-twitter:clientId]" class="col-xs-3 control-label">{{ t("security_setting.clientID") }}</label>
  34. <div class="col-xs-6">
  35. <input class="form-control" type="text" name="settingForm[security:passport-twitter:clientId]" value="{{ settingForm['security:passport-twitter:clientId'] || '' }}">
  36. <p class="help-block">
  37. <small>
  38. {{ t("security_setting.Use env var if empty", "OAUTH_GOOGLE_CLIENT_ID") }}
  39. </small>
  40. </p>
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <label for="settingForm[security:passport-google:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  45. <div class="col-xs-6">
  46. <input class="form-control" type="text" name="settingForm[security:passport-google:clientSecret]" value="{{ settingForm['security:passport-google:clientSecret'] || '' }}">
  47. <p class="help-block">
  48. <small>
  49. {{ t("security_setting.Use env var if empty", "OAUTH_GOOGLE_CLIENT_SECRET") }}
  50. </small>
  51. </p>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <label for="settingForm[security:passport-twitter:callbackUrl]" class="col-xs-3 control-label">{{ t("security_setting.callback_URL") }}</label>
  56. <div class="col-xs-6">
  57. <input class="form-control" type="text" name="settingForm[security:passport-twitter:callbackUrl]" value="{{ settingForm['security:passport-twitter:callbackUrl'] || '' }}">
  58. <p class="help-block">
  59. <small>
  60. {{ t("security_setting.Use env var if empty", "OAUTH_TWITTER_CALLBACK_URL") }}
  61. </small>
  62. </p>
  63. </div>
  64. </div>
  65. <div class="form-group">
  66. <div class="col-xs-6 col-xs-offset-3">
  67. <div class="checkbox checkbox-info">
  68. <input type="checkbox" id="bindByUserName-Google" name="settingForm[security:passport-google:isSameUsernameTreatedAsIdenticalUser]" value="1"
  69. {% if settingForm['security:passport-google:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  70. <label for="bindByUserName-Google">
  71. {{ t("security_setting.Treat username matching as identical", "username") }}
  72. </label>
  73. <p class="help-block">
  74. <small>
  75. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  76. </small>
  77. </p>
  78. </div>
  79. </div>
  80. </div>
  81. </fieldset>
  82. <div class="form-group" id="btn-update">
  83. <div class="col-xs-offset-3 col-xs-6">
  84. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  85. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  86. </div>
  87. </div>
  88. </form>
  89. {# Help Section #}
  90. <hr>
  91. <h4>
  92. <i class="fa fa-question-circle" aria-hidden="true"></i>
  93. <a href="#collapseHelpForTwitterOauth" data-toggle="collapse">How to configure Twitter OAuth?</a>
  94. </h4>
  95. <ol id="collapseHelpForTwitterOauth" class="collapse">
  96. <li>{{ t("security_setting.OAuth.Twitter.register_1", "https://console.cloud.google.com/apis/credentials", "Google Cloud Platform API Manager") }}</li>
  97. <li>{{ t("security_setting.OAuth.Twitter.register_2") }}</li>
  98. <li>{{ t("security_setting.OAuth.Twitter.register_3") }}</li>
  99. <li>{{ t("security_setting.OAuth.Twitter.register_4", "https://${growi.host}/passport/google/callback", "${growi.host}") }}</li>
  100. <li>{{ t("security_setting.OAuth.Twitter.register_5") }}</li>
  101. </ol>
  102. <script>
  103. $('input[name="settingForm[security:passport-twitter:isEnabled]"]').change(function() {
  104. const isEnabled = ($(this).val() === "true");
  105. if (isEnabled) {
  106. $('#passport-twitter-hide-when-disabled').show(400);
  107. }
  108. else {
  109. $('#passport-twitter-hide-when-disabled').hide(400);
  110. }
  111. });
  112. </script>