twitter.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. <h4>
  26. <i class="fa fa-question-circle" aria-hidden="true"></i>
  27. <a href="#collapseHelpForTwitterOauth" data-toggle="collapse">How to configure Twitter OAuth?</a>
  28. </h4>
  29. <ol id="collapseHelpForTwitterOauth" class="collapse">
  30. <li>{{ t("security_setting.OAuth.Twitter.register_1", "https://console.cloud.google.com/apis/credentials", "Google Cloud Platform API Manager") }}</li>
  31. <li>{{ t("security_setting.OAuth.Twitter.register_2") }}</li>
  32. <li>{{ t("security_setting.OAuth.Twitter.register_3") }}</li>
  33. <li>{{ t("security_setting.OAuth.Twitter.register_4", "https://${growi.host}/passport/google/callback", "${growi.host}") }}</li>
  34. <li>{{ t("security_setting.OAuth.Twitter.register_5") }}</li>
  35. </ol>
  36. <div class="form-group">
  37. <label for="settingForm[security:passport-twitter:clientId]" class="col-xs-3 control-label">{{ t("security_setting.clientID") }}</label>
  38. <div class="col-xs-6">
  39. <input class="form-control" type="text" name="settingForm[security:passport-twitter:clientId]" value="{{ settingForm['security:passport-twitter:clientId'] || '' }}">
  40. </div>
  41. </div>
  42. <div class="form-group">
  43. <label for="settingForm[security:passport-twitter:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  44. <div class="col-xs-6">
  45. <input class="form-control" type="text" name="settingForm[security:passport-twitter:clientSecret]" value="{{ settingForm['security:passport-twitter:clientSecret'] || '' }}">
  46. </div>
  47. </div>
  48. <div class="form-group">
  49. <div class="col-xs-6 col-xs-offset-3">
  50. <div class="checkbox checkbox-info">
  51. <input type="checkbox" id="bindByUserName-Twitter" name="settingForm[security:passport-twitter:isSameUsernameTreatedAsIdenticalUser]" value="1"
  52. {% if settingForm['security:passport-twitter:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  53. <label for="bindByUserName-Twitter">
  54. {{ t("security_setting.Treat username matching as identical", "username") }}
  55. </label>
  56. <p class="help-block">
  57. <small>
  58. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  59. </small>
  60. </p>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="form-group">
  65. <label for="settingForm[security:passport-twitter:callbackUrl]" class="col-xs-3 control-label">{{ t("security_setting.callback_URL") }}</label>
  66. <div class="col-xs-6">
  67. <input class="form-control" type="text" name="settingForm[security:passport-twitter:callbackUrl]" value="{{ settingForm['security:passport-twitter:callbackUrl'] || '' }}">
  68. <p class="help-block">
  69. <small>
  70. {{ t("security_setting.Use env var if empty", "OAUTH_TWITTER_CALLBACK_URL") }}
  71. </small>
  72. </p>
  73. </div>
  74. </div>
  75. </fieldset>
  76. <div class="form-group" id="btn-update">
  77. <div class="col-xs-offset-3 col-xs-6">
  78. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  79. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  80. </div>
  81. </div>
  82. </form>
  83. {# Help Section #}
  84. <hr>
  85. <h4>
  86. <i class="fa fa-question-circle" aria-hidden="true"></i>
  87. <a href="#collapseHelpForTwitterOauth" data-toggle="collapse">How to configure Google OAuth?</a>
  88. </h4>
  89. <ol id="collapseHelpForTwitterOauth" class="collapse">
  90. <li>{{ t("security_setting.OAuth.Twitter.register_1", "https://console.cloud.google.com/apis/credentials", "Google Cloud Platform API Manager") }}</li>
  91. <li>{{ t("security_setting.OAuth.Twitter.register_2") }}</li>
  92. <li>{{ t("security_setting.OAuth.Google.register_3") }}</li>
  93. <li>{{ t("security_setting.OAuth.Google.register_4", "https://${growi.host}/passport/google/callback", "${growi.host}") }}</li>
  94. <li>{{ t("security_setting.OAuth.Google.register_5") }}</li>
  95. </ol>
  96. <script>
  97. $('input[name="settingForm[security:passport-twitter:isEnabled]"]').change(function() {
  98. const isEnabled = ($(this).val() === "true");
  99. if (isEnabled) {
  100. $('#passport-twitter-hide-when-disabled').show(400);
  101. }
  102. else {
  103. $('#passport-twitter-hide-when-disabled').hide(400);
  104. }
  105. });
  106. </script>